Back
I'm trying to unzip a csv file and pass it into pandas so I can work on the file.
The code I have tried so far is:
import requests, zipfile, StringIOr = requests.get('http://data.octo.dc.gov/feeds/crime_incidents/archive/crime_incidents_2013_CSV.zip')z = zipfile.ZipFile(StringIO.StringIO(r.content))crime2013 = pandas.read_csv(z.read('crime_incidents_2013_CSV.csv'))
import requests, zipfile, StringIO
r = requests.get('http://data.octo.dc.gov/feeds/crime_incidents/archive/crime_incidents_2013_CSV.zip')
z = zipfile.ZipFile(StringIO.StringIO(r.content))
crime2013 = pandas.read_csv(z.read('crime_incidents_2013_CSV.csv'))
After the last line, although python is able to get the file, I get a "does not exist" at the end of the error.
Can someone tell me what I'm doing incorrectly?
Here is an implementation of the read_csv methods to read a zipped or a tar.gz file into pandas dataframe:
df = pd.read_csv('filename.tar.gz', compression='gzip', header=0, sep=',', quotechar='"')
31k questions
32.8k answers
501 comments
693 users