Convert a CSV file to JSON with attributes for Panic Status Board.
Developed for Linux
-- but can be easily adapted to Windows
or OS X
by commenting out the Dropbox method.
csv-to-json.rb
is a Ruby program that takes in a file from the web, attemps to convert it to JSON and uploads the file to your Dropbox account with andreafabrizi's Dropbox-Uploader BASH script.
Input CSV file:
Daily Change,Open,Closed
5/4/9000 15:27:51, 169, 1024
Output JSON file:
{
"graph":{
"title":"Daily Change",
"type":"bar",
"datasequences":[
{
"title":"open",
"datapoints":[
{
"title":"5/4/9000 15:53:11",
"value":169
}
],
"color":"red"
},
{
"title":"closed",
"datapoints":[
{
"title":"5/4/9000 15:53:11",
"value":1053
}
],
"color":"green"
}
]
}
}
- Ruby 2.0.0p0 -- This may work with other versions of Ruby but I haven't tested it
- rubygems
- json gem
- cURL -- Needed for Dropbox-Uploader
Clone this repository:
git clone https://github.com/mztriz/csv-to-json.git
Edit: csv-to-json.rb
with your favorite editor and put your CSV Dropbox links into the script
read("http://dl.dropbox.com/s/i4ml33t-n0t/sexy-data.csv")
Run:
ruby csv-to-json.rb
Add it to your Crontab to have it refresh the data from your Dropbox file every N times.
Enjoy!
The contents of this repository are released under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
See http://creativecommons.org/licenses/by-sa/3.0/ for more information.