Skip to content

Instantly share code, notes, and snippets.

@amalgjose
Created March 10, 2020 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amalgjose/edf665cf30e0b40d7623a71db662c300 to your computer and use it in GitHub Desktop.
Save amalgjose/edf665cf30e0b40d7623a71db662c300 to your computer and use it in GitHub Desktop.
import csv
import json
csv_file = open('data.csv', 'r')
json_file = open('data.json', 'w')
fieldnames = ("EmpID","FirstName","LastName","Salary")
reader = csv.DictReader( csv_file, fieldnames)
for row in reader:
json.dump(row, json_file)
json_file.write('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment