Skip to content

Instantly share code, notes, and snippets.

@samrat
Created September 17, 2011 08:52
Show Gist options
  • Save samrat/1223766 to your computer and use it in GitHub Desktop.
Save samrat/1223766 to your computer and use it in GitHub Desktop.
Converting CSV file(from Google Spreadsheet) to JSON
# 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