remove header line when reading/writing files

RyanL ryanlauritsen at
Fri Oct 12 00:52:55 CEST 2007

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')
dirlist = os.listdir(os.curdir)
for item in dirlist:
	if os.path.isdir(item):
		filelist = glob.glob("*.gz")
		for zipfile in filelist:
			filein = gzip.GzipFile(zipfile,'r')
			filecontent =

More information about the Python-list mailing list