Created
December 19, 2016 19:14
-
-
Save alastairparagas/0f1d9405383dd55d062f392189cfeac0 to your computer and use it in GitHub Desktop.
CSV to JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import json | |
| import sys | |
| f = open(sys.argv[1], 'rU') | |
| reader = csv.DictReader( f, fieldnames = ( fieldname0","fieldname1","fieldname2","fieldname3")) | |
| records = [ row for row in reader ] | |
| records.pop(0) | |
| out = json.dumps(records) | |
| f = open( '/path/to/parsed.json', 'w') | |
| f.write(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment