Skip to content

Instantly share code, notes, and snippets.

@mjcreativeventures
Created February 15, 2016 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjcreativeventures/d3295c9341264483b7ce to your computer and use it in GitHub Desktop.
Save mjcreativeventures/d3295c9341264483b7ce to your computer and use it in GitHub Desktop.
Convert CSV data to Javascript
timings = [ row.strip().split('\t') for row in file('timings.csv') ]
dups = dict()
dup_count = 0
with open('timings.js', 'w') as outf:
outf.write('var timings = [\n')
for row in timings:
line = ','.join(row)
if not dups.has_key(line):
outf.write('[ %s ],\n' % line)
dups[line] = True
else:
dup_count += 1
outf.write('];\n')
print 'Found %d duplicates.' % dup_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment