Skip to content

Instantly share code, notes, and snippets.

@FlaviuSim
Created March 1, 2012 00:27
Show Gist options
  • Save FlaviuSim/1946122 to your computer and use it in GitHub Desktop.
Save FlaviuSim/1946122 to your computer and use it in GitHub Desktop.
import csv, sys
lengths = {}
with open(sys.argv[1], 'rt') as f:
reader = csv.DictReader(f, delimiter='|')
for index, row in enumerate(reader):
if index == 0:
for heading in row.keys():
lengths[heading] = 0
for column in row.keys():
if (len(row[column]) > lengths[column]):
lengths[column] = len(row[column])
print lengths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment