File tree 1 file changed +7
-11
lines changed
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)
106
106
## [ Reading from a zip file] (@id zip_example)
107
107
108
108
``` julia
109
- using ZipFile , CSV, DataFrames
109
+ using ZipArchives, Mmap , CSV, DataFrames
110
110
111
111
a = DataFrame (a = 1 : 3 )
112
112
CSV. write (" a.csv" , a)
@@ -116,22 +116,18 @@ CSV.write("a.csv", a)
116
116
;zip a. zip a. csv
117
117
118
118
# 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
123
123
124
124
# read file from zip archive
125
- z = ZipFile . Reader ( " a.zip" ) # or "a2.zip"
125
+ z = ZipReader ( mmap ( open ( " a.zip" )) ) # or "a2.zip"
126
126
127
127
# 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
131
129
132
130
a == a_copy
133
-
134
- close (z)
135
131
```
136
132
137
133
## [ Column names on 2nd row] (@id second_row_header)
You can’t perform that action at this time.
0 commit comments