Skip to content

Instantly share code, notes, and snippets.

@kosho
Created April 13, 2017 09:14
Show Gist options
  • Save kosho/e4880fa71c3360cb00f1cbd59f3fc8a5 to your computer and use it in GitHub Desktop.
Save kosho/e4880fa71c3360cb00f1cbd59f3fc8a5 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import sys
import codecs
import csv
import json
csvfile = open(sys.argv[1], 'rU')
header_reader = csv.reader(csvfile)
header = next(header_reader)
reader = csv.DictReader(csvfile, header)
for row in reader:
print "{\"index\":{}}"
print json.dumps(row, sort_keys=False, ensure_ascii=False, encoding='utf_8')
csvfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment