Created
April 11, 2017 00:54
-
-
Save kosho/401244801931aa2e77014d15354e178a to your computer and use it in GitHub Desktop.
This file contains 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
# -*- coding: utf-8 -*- | |
import sys | |
import codecs | |
import csv | |
import json | |
# Modify the `fieldnames` with the column names of the CSV input | |
fieldnames = tuple(range(200)) | |
csvfile = open(sys.argv[1], 'rU') | |
reader = csv.DictReader(csvfile, fieldnames) | |
jsonfile=codecs.open(sys.argv[2], 'w', 'utf_8') | |
for row in reader: | |
jsonfile.write("{\"index\":{}}\n") | |
out = json.dumps(row, sort_keys=False, ensure_ascii=False, encoding='utf_8') | |
jsonfile.write(out) | |
jsonfile.write("\n") | |
csvfile.close() | |
jsonfile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment