A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/17789907/pandas-convert-winzipped-csv-file-to-data-frame below:

python - Pandas: convert WinZipped csv file to Data Frame

I have a couple of WinZipped csv files and would like to read these in as a Pandas dataframe. The problem is that neither of the decompression options ('gzip' or 'bz2') seems to work. Here's what the file looks like:

00000000011!00023011!89011!200812
00000000012!00023011!89011!200812
00000000013!00023011!89011!200812

So it seems that I am going to have to unzip the file using Python's zipfile module, read in the lines and create a dataframe from what I read in. The way I thought about doing this is creating a list of dictionaries like this:

[
    {"header1": 00000000011, "header2": 00023011, "header3": 89011, "header4": 200812}, 
    {"header1": 00000000012, "header2": 00023011, "header3": 89011, "header4": 200812},
    ...
]

and then convert this to a dataframe as in http://pandas.pydata.org/pandas-docs/stable/dsintro.html#from-a-list-of-dicts.

However, this seems to involve a lot of manual manipulating of lines - is there any better way to do this?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4