# Problem with unzippig file and reading it with CSV

**URL:** https://discourse.julialang.org/t/problem-with-unzippig-file-and-reading-it-with-csv/15645
**Category:** Data
**Tags:** question
**Created:** [September 28, 2018, 9:21pm UTC](https://discourse.julialang.org/t/problem-with-unzippig-file-and-reading-it-with-csv/15645 "2018-09-28T21:21:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)
#### Post date: [September 28, 2018, 9:21pm UTC](https://discourse.julialang.org/t/problem-with-unzippig-file-and-reading-it-with-csv/15645/1 "2018-09-28T21:21:42Z")

</div>

I’m having issues now with a code that was working before and will appreciate any help to solve this, because despite some comments from @quinnj on the Slack, I still haven’t been able to figure it out.

I’m downloading some Zip packages from a FTP server using FTPClient.jl

```julia
ftp_init()
options = RequestOptions(hostname="transfer.cdpr.ca.gov/pub/outgoing/pur_archives/"
Zipped_file = ftp_get(options, name_of_file.zip)
ftp_cleanup()

```

These Zip files contain about 76 compressed files, most of them .txt, with information I need regarding chemical use in agriculture in California. As extra information, this is the only way to obtain the data, as they don’t have a public API. Also, most of the files are not needed, so I prefer not to save them on disk, so I have a function that will unzip the files on memory, read their names and only open whatever file was requested.

```julia
using ZipFile, CSV, DataFrames

# Zipped_files.files is an IO buffer
unzipped_file = ZipFile.Reader(Zipped_file.files)
# unizipped file opens as expected and a list of all 70 plus file can be seen
file_of_interest = CSV.read(unzipped_file.files[index_file__of_interest])

```

This used to work but I believe that after the CSV upgrade something broke it and I get the following error:

```julia
Error: type ReadableFile has no field mark

```

As mentioned before, @quinnj told me on Slack that the problem appears to be that “ZipFile.Reader does not fully implement the normal IO methods”, causing CSV to fail. He also suggested reading the file into a byte array. I’ve spent some time trying to get that suggestion to work and haven’t been able to figure it out, so any help is welcome. Also, if there’s any other (better?) way to deal with zip files, I’ll also would like to know.

---

<div class="post-metadata">

### Author: ![y4lu](https://avatars.discourse-cdn.com/v4/letter/y/47e85d/32.png) [@y4lu](https://discourse.julialang.org/u/y4lu)
#### Post date: [September 29, 2018, 4:43am UTC](https://discourse.julialang.org/t/problem-with-unzippig-file-and-reading-it-with-csv/15645/2 "2018-09-29T04:43:35Z")

</div>

Hopefully there’s a readstring() function handy

```julia
filebuffer = IOBuffer(readstring(unzipped_file.files[index_file__of_interest]));
file_of = CSV.read(filebuffer);
```

---

<div class="post-metadata">

### Author: ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)
#### Post date: [September 29, 2018, 5:35am UTC](https://discourse.julialang.org/t/problem-with-unzippig-file-and-reading-it-with-csv/15645/3 "2018-09-29T05:35:57Z")

</div>

Thank you very much, that work. I had to change read string to read, because read string was deprecated. Otherwise seems to be exactly what I wanted.
