Created
May 30, 2017 17:25
-
-
Save annacruz/23bf1b514a318cb34230dbb668c690dc to your computer and use it in GitHub Desktop.
Parsing csv files with tab delimiter to JSON
This file contains 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 | |
csvfile = open('file1.csv', 'r') | |
jsonfile = open('file2.json', 'w') | |
fieldnames = ("firstname", "lastname", "phone", "birthdate") | |
reader = csv.DictReader( csvfile, fieldnames, delimiter='\t') | |
for row in reader: | |
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