unzip (zip, tar, tag.gz) files with ruby

To extract files from a .tar.gz file you can use the following methods from packages distributed with Ruby: require ‘rubygems/package’ require ‘zlib’ tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(‘Path/To/myfile.tar.gz’)) tar_extract.rewind # The extract has to be rewinded after every iteration tar_extract.each do |entry| puts entry.full_name puts entry.directory? puts entry.file? # puts entry.read end tar_extract.close Each entry of type Gem::Package::TarReader::Entry … Read more

Maven best practice for creating ad hoc zip artifact

Decide what classifier you will use for your zip file, for sake of argument let’s say it would be sample. In your project create file assembly/sample.xml Fill in assembly/sample.xml with something like this: <?xml version=”1.0″ encoding=”UTF-8″?> <assembly xmlns=”http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=” http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd” > <id>sample</id> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <outputDirectory>/</outputDirectory> <directory>some/directory/in/your/project</directory> </fileSet> </fileSets> <!– use … Read more

Read a zipped file as a pandas DataFrame

If you want to read a zipped or a tar.gz file into pandas dataframe, the read_csv methods includes this particular implementation. df = pd.read_csv(‘filename.zip’) Or the long form: df = pd.read_csv(‘filename.zip’, compression=’zip’, header=0, sep=’,’, quotechar=”””) Description of the compression argument from the docs: compression : {‘infer’, ‘gzip’, ‘bz2’, ‘zip’, ‘xz’, None}, default ‘infer’ For on-the-fly … Read more

Unzip dependency in maven

You can do it with dependencies:unpack-dependencies: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.2</version> <executions> <execution> <id>unpack-sigar</id> <phase>package<!– or any other valid maven phase –></phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <includeGroupIds>org.hyperic</includeGroupIds> <includeArtifactIds>sigar-dist</includeArtifactIds> <outputDirectory> ${project.build.directory}/wherever/you/want/it <!– or: ${project.basedir}/wherever/you/want/it –> </outputDirectory> </configuration> </execution> </executions> </plugin> Reference: Unpacking project dependencies dependency:unpack-dependencies

Download multiple files as a zip folder using php [duplicate]

you can take a look at ZipArchive, you would be able to create zips with that and let the user download it. Cletus provide a really good answer there. I humbly copy his sample here $files = array(‘readme.txt’, ‘test.html’, ‘image.gif’); $zip = new ZipArchive; $zip->open(‘file.zip’, ZipArchive::CREATE); foreach ($files as $file) { $zip->addFile($file); } $zip->close(); and … Read more

List .zip directories without extracting

I suggest you have a look at ZipFile.entries(). Here’s some code: try (ZipFile zipFile = new ZipFile(“test.zip”)) { Enumeration<? extends ZipEntry> zipEntries = zipFile.entries(); while (zipEntries.hasMoreElements()) { String fileName = zipEntries.nextElement().getName(); System.out.println(fileName); } } If you’re using Java 8, you can avoid the use of the almost deprecated Enumeration class using ZipFile::stream as follows: zipFile.stream() … Read more

How to split a huge zip file into multiple volumes?

Check: http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=38&t=004618 I am not aware of any public API that will help you do that. (Although if you do not want to do it programatically, there are utilities like WinSplitter that will do it) I have not tried it but, every ZipEntry while using ZippedInput/OutputStream has a compressed size. You may get a rough … Read more