Skip to content

Instantly share code, notes, and snippets.

@cbertelegni
Created April 13, 2016 18:02
Show Gist options
  • Save cbertelegni/7b295771f2e4f582022e77a4ee5ecf5e to your computer and use it in GitHub Desktop.
Save cbertelegni/7b295771f2e4f582022e77a4ee5ecf5e to your computer and use it in GitHub Desktop.
Convert csv file to json PY
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