Hi all, I'm writing a program to manipulate data in 3 different kind of format, there are GZIP, cvs/txt, or ZIP file.
Here is part of my program to open these 3 kind formats of file, if (option==1): file=gzip.GzipFile(sys.argv[1],"r") elif (option==2): file=open(sys.argv[1],"r") elif (option==3): archive=zipfile.ZipFile(sys.argv[1],"r") I have no problem with opening GZIP or cvs/txt file. However for the ZIP file, let says the ZIP file contains only one member, >>> archive.namelist() ['CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv'] I would like to open the csv file with folowwing command, file=archive.open("CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv","r") But it turned out error, Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: ZipFile instance has no attribute 'open' Do you know the way to open an file from a ZIP archive, but not reading them all into memory. I would manipulate each line using "for line in file:" Hope my contents do make sense. Thanks, phoebe
-- http://mail.python.org/mailman/listinfo/python-list