Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2013 12:42
Show Gist options
  • Save anonymous/5583728 to your computer and use it in GitHub Desktop.
Save anonymous/5583728 to your computer and use it in GitHub Desktop.
Quick demo of decoding a Latin-1 encoded IIS log with www2csv
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