File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ file = CSV.File(http_response)
106106## [ Reading from a zip file] (@id zip_example)
107107
108108``` julia
109- using ZipFile , CSV, DataFrames
109+ using ZipArchives, Mmap , CSV, DataFrames
110110
111111a = DataFrame (a = 1 : 3 )
112112CSV. write (" a.csv" , a)
@@ -116,22 +116,18 @@ CSV.write("a.csv", a)
116116;zip a. zip a. csv
117117
118118# alternatively, write directly into the zip archive (without creating an unzipped csv file first)
119- z = ZipFile . Writer (" a2.zip" )
120- f = ZipFile . addfile (z, " a.csv" , method = ZipFile . Deflate )
121- a |> CSV. write (f )
122- close (z)
119+ ZipWriter (" a2.zip" ) do z
120+ zip_newfile (z, " a.csv" ; compress = true )
121+ a |> CSV. write (z )
122+ end
123123
124124# read file from zip archive
125- z = ZipFile . Reader ( " a.zip" ) # or "a2.zip"
125+ z = ZipReader ( mmap ( open ( " a.zip" )) ) # or "a2.zip"
126126
127127# identify the right file in zip
128- a_file_in_zip = filter (x-> x. name == " a.csv" , z. files)[1 ]
129-
130- a_copy = CSV. File (a_file_in_zip) |> DataFrame
128+ a_copy = CSV. File (zip_openentry (z, " a.csv" )) |> DataFrame
131129
132130a == a_copy
133-
134- close (z)
135131```
136132
137133## [ Column names on 2nd row] (@id second_row_header)
You can’t perform that action at this time.
0 commit comments