|
|
Java utility to convert csv data to json. It was originally written quickly so I could more easily browse the content available from DataGM.
It may fail to download larger datasets (download them manually and paste the data into the CSV area instead) and there's little error checking.
The JSON classes may also fail on a large amount of data - this was thrown together and the code is completely ad-hoc, don't use it for anything serious.
You can paste the output into the JSON Viewer to browse the JSON in nicely formatted html.
Download - version 1.0 First Release
Download - version 1.1 Added file saving and some error handling
Download - version 1.2.1 Command line operation and batch processing
Command-line instructions:
- java2csv.jar C:\somedir\somedata.csv - one .csv argument will convert somedata.csv to somedata.json and save it in somedir/
- java2csv.jar C:\somedir - one directory argument will batch convert all .csv files in somedir/ and save them to the same directory
- java2csv.jar C:\somedir\somedata.csv C:\someotherdir - a .csv argument and a directory will convert somedata.csv to somedata.json and save it in somotherdir/
- java2csv.jar C:\somedir C:\someotherdir - two directory arguments will batch convert all .csv files from somedir/ to someotherdir/
The utility uses the OpenCSV library and the JSON classes (intended for J2ME devices) from json.org
Example URL to try: http://store.datagm.org.uk/sets/fire/Attacks_on_Firefighters_2010-11.csv


