Created
October 26, 2015 14:04
-
-
Save basil2style/18da8cd98d8ceb9b2bc7 to your computer and use it in GitHub Desktop.
csv url to json convertor
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
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