473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

read zipfile sequentially?

I have a large ASCII data set that is zipped to a reasonable size.
Can I access the data without decompressing the whole file first?
I would like to run through the data to produce a much smaller
extract and some summary statistics, but without unzipping
it (if that is even possible).
Thanks,
Alan Isaac
Oct 15 '08 #1
2 1125
I have a large ASCII data set that is zipped to a reasonable size.
Can I access the data without decompressing the whole file first?
I would like to run through the data to produce a much smaller
extract and some summary statistics, but without unzipping
it (if that is even possible).
Yes, if you're willing to slightly hack your install if you're
running pre-2.6 Python.

I had the same question, and Gabriel suggested[2] I try dropping
the 2.6 version of zipfile.py in my $PYTHONPATH so it's found
before the existing version.

Once available, you can use the ZipFile.open() method which has
an iterator you can use rather than reading the entire content
into memory. You can read through the thread for further details.

Works on My Machine(tm)[3]

-tkc

[1]
http://mail.python.org/pipermail/pyt...er/469254.html

[2]
http://mail.python.org/pipermail/pyt...er/469320.html

[3]
http://www.codinghorror.com/blog/archives/000818.html


Oct 15 '08 #2
On 10/15/2008 3:13 PM Tim Chase apparently wrote:
http://mail.python.org/pipermail/pyt...er/469320.html
Ask and ye shall receive...
Thank you!
Alan Isaac
Oct 15 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
17
by: Guyon Morée | last post by:
what is the difference? if I open a text file in binary (rb) mode, it doesn't matter... the read() output is the same.
0
by: Ian Cook | last post by:
Hi, I'm new to python so please excuse me if this is a 'dumb' question. I want to use the ZipFile module to UPDATE, rather than append, or create a new zip file. Does anyone know how this can...
1
by: Waitman Gobble | last post by:
Hello, I am new to Python. I am having trouble with zipfile.py. On a Linux machine with python 2.4.2 I have trouble opening a zipfile. Python is complaining about the bit where it does a...
5
by: Waguy | last post by:
Hi all, I am new to python and want to create a process to unzip large numbers of zip files I get from a SOAP application. The files all have a ZIP extention and can be unzipped using WinZip. ...
3
bvdet
by: bvdet | last post by:
Following is an example that may provide a solution to you: """ Function makeArchive is a wrapper for the Python class zipfile.ZipFile 'fileList' is a list of file names - full path each name...
9
by: flebber | last post by:
I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b") and write it out . the compressed "*.k3b" file has two file and the one I was trying...
2
by: Kevin Ar18 | last post by:
I posted this on the forum, but nobody seems to know the solution: http://python-forum.org/py/viewtopic.php?t=5230 I have a zip file that is several GB in size, and one of the files inside of it...
1
by: John Machin | last post by:
On Jun 4, 8:06 pm, jwesonga <crazylun...@gmail.comwrote: Nothing is ever as it seems. Let's try to work backwards from the error message ... and we don't need your magnificent script, just the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.