Created
August 21, 2018 20:38
-
-
Save defvol/123a004d5d4358b63741173180c46b46 to your computer and use it in GitHub Desktop.
Simple python script to transform CSV 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
# usage: python csv-to-json.py the.csv | |
# based on https://stackoverflow.com/questions/3428532/how-to-import-a-csv-file-using-python-with-headers-intact-where-first-column-is#3428562 | |
import csv | |
import json | |
import sys | |
csvfile = open(sys.argv[1], 'r') | |
reader = csv.DictReader(csvfile) | |
out = json.dumps( [ row for row in reader ] ) | |
sys.stdout.write(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment