Skip to content

Instantly share code, notes, and snippets.

@basil2style
Created October 26, 2015 14:04
Show Gist options
  • Save basil2style/18da8cd98d8ceb9b2bc7 to your computer and use it in GitHub Desktop.
Save basil2style/18da8cd98d8ceb9b2bc7 to your computer and use it in GitHub Desktop.
csv url to json convertor
import csv
import json
import urllib2
jsonfile = open('file.json') # Saving json in local disk
url = "YOUR CSV URL HERE"
response = urllib2.urlopen(url)
fieldnames= ("f1","f2","f3") # These are the JSON feild names
cr = csv.DictReader(response,fieldnames,delimiter="|")
for row in cr:
json.dump(row,jsonfile)
jsonfile.write('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment