2 json snippets
Snippets are tiny notes I've collected for easy reference.
Python one-liner for reading a CSV file into a JSON array of arrays
Reading a CSV file into 2-d Python array (an array of arrays):
import csv
array = list(csv.reader(open( MYFILE.csv )))
Dumping that as JSON (via the command-line):
$ python -c "import json,csv;print json.dumps(list(csv.reader(open( CSV-FILENAME ))))"
Published 15 Feb 2014
Snippets are tiny notes I've collected for easy reference.