I'm a newbie with a large number of data files in multiple directories. I want to uncompress, read, and copy the contents of each file into one master data file. The code below seems to be doing this perfectly. The problem is each of the data files has a header row in the first line, which I do not want in the master file. How can I skip that first line when writing to the master file? Any help is much appreciated. Thank you.
import os import sys import glob import gzip zipdir = "G:/Research/Data/" outfilename = "G:/Research/Data/master_data.txt" outfile = open(outfilename,'w') os.chdir(zipdir) dirlist = os.listdir(os.curdir) for item in dirlist: if os.path.isdir(item): os.chdir(item) filelist = glob.glob("*.gz") for zipfile in filelist: filein = gzip.GzipFile(zipfile,'r') filecontent = filein.read() filein.close() outfile.write(filecontent) os.chdir(os.pardir) outfile.close() -- http://mail.python.org/mailman/listinfo/python-list