Created
April 13, 2016 18:02
-
-
Save cbertelegni/7b295771f2e4f582022e77a4ee5ecf5e to your computer and use it in GitHub Desktop.
Convert csv file to json PY
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 | |
file_name = "file_name.csv" | |
f = open(file_name, "r") | |
output = open(file_name.replace(".csv", ".json"),'w') | |
reader = csv.DictReader(f) | |
json.dump([r for r in reader], output,indent=4,sort_keys=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment