Skip to content

Instantly share code, notes, and snippets.

@waveform80
Forked from anonymous/gist:5583728
Created May 15, 2013 12:43
Show Gist options
  • Save waveform80/5583733 to your computer and use it in GitHub Desktop.
Save waveform80/5583733 to your computer and use it in GitHub Desktop.
def process_iis_directory(d):
print('Processing IIS directory %s' % d)
for entry in os.listdir(d):
entry = os.path.join(d, entry)
if entry.endswith('.gz'):
print('Processing %s into CSV' % entry)
with gzip.open(entry, 'rb') as uncompressed, \
io.BufferedReader(uncompressed) as buffered, \
io.TextIOWrapper(buffered, encoding='latin1') as infile, \
io.open(os.path.splitext(entry)[0] + '.csv', 'wb') as outfile, \
iis.IISSource(infile) as source, \
csv.CSVTarget(outfile) as target:
for row in source:
target.write(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment