# CSV ZipFile read example broken in Julia 1.11.0

**URL:** https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204
**Category:** General Usage
**Created:** [October 11, 2024, 6:38pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204 "2024-10-11T18:38:11Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [October 11, 2024, 6:38pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/1 "2024-10-11T18:38:11Z")

</div>

I am using 1.11.0 on a Windows machine with

```julia
(jl_FpGwGs) pkg> st
Status `C:\Users\jakez\AppData\Local\Temp\jl_FpGwGs\Project.toml`
  [336ed68f] CSV v0.10.14
  [a93c6f00] DataFrames v1.7.0
  [a5390f91] ZipFile v0.10.1

```

In the [CSV docs](https://csv.juliadata.org/stable/examples.html#zip_example) just under the title `Reading from a zip file`, the example fails at the line `a_copy = CSV.File(a_file_in_zip) |> DataFrame` specifically at the `CSV.File(a_file_in_zip)` command.

Any hints?

---

<div class="post-metadata">

### Author: ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)
#### Post date: [October 11, 2024, 7:25pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/2 "2024-10-11T19:25:32Z")

</div>

> [@Jake](#):
>
> fails at the line

Please share the error message with us 🙂 Just copy-paste it and post it as code block.

---

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [October 11, 2024, 8:00pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/3 "2024-10-11T20:00:07Z")

</div>

This was done with CSV 0.10.13 rather than 0.10.14, but the same error.

```julia
julia> z = ZipFile.Reader("a.zip")
ZipFile.Reader for IOStream(<file a.zip>) containing 1 files:

uncompressedsize method mtime name
----------------------------------------------
               8 Store 2024-10-11 14-23 a.csv

julia> a_file_in_zip = filter(x->x.name == "a.csv", z.files)[1]
ZipFile.ReadableFile(name=a.csv, method=Store, uncompresssedsize=8, compressedsize=8, mtime=1.728671032e9)

julia> a_copy = CSV.File(a_file_in_zip) |> DataFrame
ERROR: IOError: unlink("C:\\Users\\jakez\\AppData\\Local\\Temp\\jl_1E5A.tmp"): permission denied (EACCES)
Stacktrace:
 [1] uv_error
   @ .\libuv.jl:106 [inlined]
 [2] unlink(p::String)
   @ Base.Filesystem .\file.jl:1105
 [3] rm(path::String; force::Bool, recursive::Bool)
   @ Base.Filesystem .\file.jl:283
 [4] rm
   @ .\file.jl:273 [inlined]
 [5] CSV.File(ctx::CSV.Context, chunking::Bool)
   @ CSV C:\Users\jakez\.julia\packages\CSV\cwX2w\src\file.jl:344
 [6] File
   @ C:\Users\jakez\.julia\packages\CSV\cwX2w\src\file.jl:227 [inlined]
 [7] #File#32
   @ C:\Users\jakez\.julia\packages\CSV\cwX2w\src\file.jl:223 [inlined]
 [8] CSV.File(source::ZipFile.ReadableFile)
   @ CSV C:\Users\jakez\.julia\packages\CSV\cwX2w\src\file.jl:162
 [9] top-level scope
   @ REPL[16]:1

julia>

```

---

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [October 11, 2024, 8:49pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/4 "2024-10-11T20:49:59Z")

</div>

The example works with Julia 1.10.5. It was a good reason to finally install Juliaup and conveniently switch between versions of Julia.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [October 11, 2024, 9:51pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/5 "2024-10-11T21:51:00Z")

</div>

> [@Jake](#):
>
> `IOError: unlink("C:\\Users\\jakez\\AppData\\Local\\Temp\\jl_1E5A.tmp"): permission denied (EACCES)`

Maybe it switched to a new temporary directory between versions, and for the new one `C:\\Users\\jakez\\AppData\\Local\\Temp` you don’t have permissions set up correctly?

---

<div class="post-metadata">

### Author: ![oscarvdvelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscarvdvelde/32/202157_2.png) [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)
#### Post date: [October 11, 2024, 10:19pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/6 "2024-10-11T22:19:58Z")

</div>

I reported this as a bug several months ago:

> <https://github.com/JuliaData/CSV.jl/issues/1137>
>
> \`\`
> \[test3.dat.gz\](https://github.com/user-attachments/files/16286492/test3.dat.…gz)
> \`
> \`\`\`
> julia\> lmadata = CSV.File(raw"C:\\Users\\oscar\\Documents\\Work\\Julia\\test3.dat.gz")
> ERROR: IOError: unlink("C:\\\\Users\\\\oscar\\\\AppData\\\\Local\\\\Temp\\\\jl\_F294.tmp"): permission denied (EACCES)
> Stacktrace:
> \[1\] uv\_error
> @ .\\libuv.jl:106 \[inlined\]
> \[2\] unlink(p::String)
> @ Base.Filesystem .\\file.jl:1105
> \[3\] rm(path::String; force::Bool, recursive::Bool)
> @ Base.Filesystem .\\file.jl:283
> \[4\] rm
> @ .\\file.jl:273 \[inlined\]
> \[5\] CSV.File(ctx::CSV.Context, chunking::Bool)
> @ CSV C:\\Users\\oscar\\.julia\\packages\\CSV\\cwX2w\\src\\file.jl:344
> \[6\] File
> @ C:\\Users\\oscar\\.julia\\packages\\CSV\\cwX2w\\src\\file.jl:227 \[inlined\]
> \[7\] #File#32
> @ C:\\Users\\oscar\\.julia\\packages\\CSV\\cwX2w\\src\\file.jl:223 \[inlined\]
> \[8\] CSV.File(source::String)
> @ CSV C:\\Users\\oscar\\.julia\\packages\\CSV\\cwX2w\\src\\file.jl:162
> 
> julia\> lmadata = CSV.File(raw"C:\\Users\\oscar\\Documents\\Work\\Julia\\test3.dat.gz",header=false,delim=' ', ignorerepeated=true)
> ERROR: IOError: unlink("C:\\\\Users\\\\oscar\\\\AppData\\\\Local\\\\Temp\\\\jl\_B18B.tmp"): permission denied (EACCES)
> Stacktrace:
> \[1\] uv\_error
> @ .\\libuv.jl:106 \[inlined\]
> \[2\] unlink(p::String)
> @ Base.Filesystem .\\file.jl:1105
> \[3\] rm(path::String; force::Bool, recursive::Bool)
> @ Base.Filesystem .\\file.jl:283
> \[4\] rm
> @ .\\file.jl:273 \[inlined\]
> \[5\] CSV.File(ctx::CSV.Context, chunking::Bool)
> @ CSV C:\\Users\\oscar\\.julia\\packages\\CSV\\cwX2w\\src\\file.jl:344
> \[6\] File
> @ C:\\Users\\oscar\\.julia\\packages\\CSV\\cwX2w\\src\\file.jl:227 \[inlined\]
> \[7\] #File#32
> @ C:\\Users\\oscar\\.julia\\packages\\CSV\\cwX2w\\src\\file.jl:223 \[inlined\]
> \[8\] top-level scope
> @ REPL\[45\]:1
> 
> \`\`\`
> 
> Julia Version 1.11.0-rc1
> Commit 3a35aec36d (2024-06-25 10:23 UTC)
> Build Info:
> Official https://julialang.org/ release
> Platform Info:
> OS: Windows (x86\_64-w64-mingw32)
> CPU: 16 × 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
> WORD\_SIZE: 64
> LLVM: libLLVM-16.0.6 (ORCJIT, tigerlake)
> Threads: 16 default, 0 interactive, 8 GC (on 16 virtual cores)
> Environment:
> JULIA\_EDITOR = code
> 
> CSV v0.10.14
> 
> dat.gz file is attached.
> 
> Note: it works fine on the raw data.

and this thread:

> [@CSV.jl bug reading .gz file in Julia 1.11-rc](https://discourse.julialang.org/t/csv-jl-bug-reading-gz-file-in-julia-1-11-rc/117341):
>
> Hello, I tried version 1.11.0-rc and noted a file access error reading a gzipped file with CSV.File, which does not happen in 1.10.4. julia\> data = CSV.File(raw"C:\Users\oscar\Documents\Work\Julia\test3.dat.gz") ERROR: IOError: unlink("C:\\Users\\oscar\\AppData\\Local\\Temp\\jl\_D028.tmp"): permission denied (EACCES) Stacktrace: [1] uv\_error @ .\libuv.jl:106 [inlined] [2] unlink(p::String) @ Base.Filesystem .\file.jl:1105 [3] rm(path::String; force::Bool, recursive::Bool) @ Base.Fil…

---

<div class="post-metadata">

### Author: ![oscarvdvelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscarvdvelde/32/202157_2.png) [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)
#### Post date: [October 12, 2024, 12:53am UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/7 "2024-10-12T00:53:19Z")

</div>

I have not tried 1.11 yet, but I noted that `CSV.File` has the option `buffer_in_memory=true`, perhaps it will avoid the error since no temporary file is created. Could you try it?

---

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [October 14, 2024, 12:08pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/8 "2024-10-14T12:08:08Z")

</div>

Okay it seems that there might be two problems, one to do with file permissions and another one. Let’s start with the one where I work in a directory where I know I have write permissions. Taking it directly from the example referred to in post 1:

> Blockquote  
> I have not tried 1.11 yet, but I noted that `CSV.File` has the option `buffer_in_memory=true` , perhaps it will avoid the error since no temporary file is created. Could you try it?

The following is with and without the `buffer\_in\_memory=true’ option.

```julia
julia> z = ZipFile.Reader("a2.zip") # or "a2.zip"
ZipFile.Reader for IOStream(<file a2.zip>) containing 1 files:

uncompressedsize method mtime name
----------------------------------------------
               8 Deflate 2024-10-14 07-48 a.csv

julia> a_file_in_zip = filter(x->x.name == "a.csv", z.files)[1]
ZipFile.ReadableFile(name=a.csv, method=Deflate, uncompresssedsize=8, compressedsize=10, mtime=1.728906532e9)

julia> a_copy = CSV.File(a_file_in_zip) |> DataFrame
ERROR: IOError: unlink("C:\\Users\\jakez\\AppData\\Local\\Temp\\jl_591A.tmp"): permission denied (EACCES)
Stacktrace:
 [1] uv_error
   @ .\libuv.jl:106 [inlined]
 [2] unlink(p::String)
   @ Base.Filesystem .\file.jl:1105
 [3] rm(path::String; force::Bool, recursive::Bool)
   @ Base.Filesystem .\file.jl:283
 [4] rm
   @ .\file.jl:273 [inlined]
 [5] CSV.File(ctx::CSV.Context, chunking::Bool)
   @ CSV C:\Users\jakez\.julia\packages\CSV\cwX2w\src\file.jl:344
 [6] File
   @ C:\Users\jakez\.julia\packages\CSV\cwX2w\src\file.jl:227 [inlined]
 [7] #File#32
   @ C:\Users\jakez\.julia\packages\CSV\cwX2w\src\file.jl:223 [inlined]
 [8] CSV.File(source::ZipFile.ReadableFile)
   @ CSV C:\Users\jakez\.julia\packages\CSV\cwX2w\src\file.jl:162
 [9] top-level scope
   @ REPL[13]:1

julia>

julia> a_copy = CSV.File(a_file_in_zip, buffer_in_memory=true) |> DataFrame
0×0 DataFrame

```

No error when buffer\_in\_memory=true, but it has a 0x0 DataFrame, which is incorrect.

Now going back to a temporary environment on a Win 11 machine `]activate --temp` where my write permissions are the Windows default and probably messed up, and the same example from post 1, when I try to write the zip file I also get an error as follows:

```julia
julia> z = ZipFile.Writer("a2.zip")
ERROR: SystemError: opening file "a2.zip": Permission denied
Stacktrace:
 [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
   @ Base .\error.jl:176
 [2] systemerror
   @ .\error.jl:175 [inlined]
 [3] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Bool, append::Nothing)
   @ Base .\iostream.jl:295
 [4] open
   @ .\iostream.jl:277 [inlined]
 [5] open(fname::String, mode::String; lock::Bool)
   @ Base .\iostream.jl:358
 [6] open
   @ .\iostream.jl:357 [inlined]
 [7] ZipFile.Writer(filename::String)
   @ ZipFile C:\Users\jakez\.julia\packages\ZipFile\yQ7yx\src\ZipFile.jl:179
 [8] top-level scope
   @ REPL[5]:1

```

From Windows 3.1 days and even before from DOS days, I have always put my local work in C:\data, and have found I don’t need to worry about what Windows uses for default file permissions.

---

<div class="post-metadata">

### Author: ![oscarvdvelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscarvdvelde/32/202157_2.png) [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)
#### Post date: [October 14, 2024, 5:47pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/9 "2024-10-14T17:47:53Z")

</div>

You should not need to handle the file with `ZipFile.Reader`, if there is just one file inside. `CSV.File("a2.zip", buffer_in_memory=true)` would do the trick, with `CSV.read("a2.zip", DataFrame; buffer_in_memory=true)` directly creating a DataFrame.

---

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [October 15, 2024, 11:04am UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/10 "2024-10-15T11:04:10Z")

</div>

In my use case there are many files in the zipped file. I am using the example from the manual as a MEW that works with 1.10.5 but not with 1.11.0 and reproduces the problem I am seeing with my code.

---

<div class="post-metadata">

### Author: ![nhz2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhz2/32/44428_2.png) [@nhz2](https://discourse.julialang.org/u/nhz2)
#### Post date: [October 17, 2024, 7:50pm UTC](https://discourse.julialang.org/t/csv-zipfile-read-example-broken-in-julia-1-11-0/121204/11 "2024-10-17T19:50:21Z")

</div>

This PR should fix this issue [Fix reading gzipped file in Julia 1.11 on Windows by nhz2 · Pull Request #1144 · JuliaData/CSV.jl · GitHub](https://github.com/JuliaData/CSV.jl/pull/1144)
