ZIP Archive Interface. Wrapper for Info-ZIP (and ZipFile.jl).
6 Stars
Updated Last
2 Years Ago
Started In
January 2016


This module provides support for reading and writing ZIP archives in Julia.

Build Status


Install via the Julia package manager, Pkg.add("InfoZIP").

Depends on the Info ZIP zip and uzip tools. If these are not installed the ZipFile.jl library is used instead.


InfoZIP.unzip(archive, [outputdir]) extracts an archive to files in "outputdir" (or in the current directory by default).

InfoZIP.unzip("", "/tmp/")

InfoZIP.unzip(http_get("", "/tmp/"))

High level interface

Use open_zip open a ZIP Archive for read and/or write.

Use create_zip to create a new ZIP Archive in one step.

A ZIP Archive can be either a .ZIP file or an Array{UInt8,1}.


The result of open_zip(archive) is iterable and can be accessed as an Associative collection.

# Print size of each file in ""...
for (filename, data) in open_zip("")
    println("$filename has $(length(data)) bytes")

# Read contents of "bar.csv" from ""...
data = open_zip("")["foo/bar.csv"]

# Read "" from in-memory ZIP archive...
zip_data = http_get("")
csv_data = open_zip(zip_data)["bar.csv"]

# Create a Dict from a ZIP archive...
Dict{AbstractString,Any} with 2 entries:
  "hello.txt"    => "Hello!\n"
  "foo/text.txt" => "text\n"

# Create "" with two files...
open_zip("", "w") do z
    z["hello.txt"] = "Hello!\n"
    z["bar.csv"] = "1,2,3\n"

# Create in-memory ZIP archive in "buf"...
buf = UInt8[]
open_zip(buf) do z
    z["hello.txt"] = "Hello!\n"
    z["bar.csv"] = "1,2,3\n"
http_put("", buf)

# Add a new file to an existing archive"...
open_zip("", "r+") do z
    z["newfile.csv"] = "1,2,3\n"

# Update an existing file in an archive"...
open_zip("", "r+") do z
    z["newfile.csv"] = lowercase(z["newfile.csv"])


create_zip([destination], content) creates a ZIP archive from "content' in a single step. If "destination" is omitted the archive is returned as Array{UInt8}.

# Create archive from Dict...
create_zip("", Dict("hello.txt" => "Hello!\n",
                           "bar.csv" => "1,2,3\n"))

# Create archive from Pairs...
create_zip("", "hello.txt" => "Hello!\n",
                      "bar.csv" => "1,2,3\n"))

# Create archive from Tuples...
zip_data = create_zip([("hello.txt", "Hello!\n"),
                       ("bar.csv" => "1,2,3\n")])

# Create archive from filenames array and data array...
zip_data = create_zip(["hello.txt", "bar.csv"],
                      ["Hello!\n",  "1,2,3\n"])

# Create archive from names of files in the current directory...
create_zip("", ["hello.txt", "bar.csv"])
zip_data = create_zip(["hello.txt", "bar.csv"])

Based on fhs/ZipFile.jl#16, thanks @timholy

Required Packages

No packages found.

Used By Packages