Created
September 17, 2011 08:52
-
-
Save samrat/1223766 to your computer and use it in GitHub Desktop.
Converting CSV file(from Google Spreadsheet) 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
# script for converting Google Spreadsheets .CSV file to JSON | |
import csv | |
import simplejson as json | |
f = open('path/to/filename.csv', 'r') | |
reader = csv.reader(f) | |
keys = ('Name', 'Address') #replace/add keys here | |
out = [] | |
out = [dict(zip(keys, property)) for property in reader] | |
out.remove(out[0]) # removing the first row- keys | |
print json.dumps(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment