Created
February 5, 2021 16:27
-
-
Save parth-paradkar/80a53b829ef8cbd57882c67dcd00a240 to your computer and use it in GitHub Desktop.
Convert CSV file with headers to JSON
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
| from sys import argv | |
| import csv | |
| import json | |
| with open(argv[1], 'r') as csv_file: | |
| reader = csv.DictReader(csv_file) | |
| data = [d for d in reader] | |
| with open("result.json", 'w') as f: | |
| json.dump(data, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment