I thought about maybe making some projects where I work with some data from my google analytics statistics. Grabbing the data is simple enough, but there is no option to download the data in *.json format, but there is an option for *.csv. So all I need is some kind of tool to help me convert data in a *.csv to *.json. I prefer to do just about everything with node.js, and as such I was able to come across something called csvtojson
To test this out I downloaded a *.csv file from within google analytics that contains the number of users that visited my site for each day of the year in 2017, which I renamed to 2017.csv.
So I have the data that I want, now I just need a way to automate the process of converting it into clean *.json for this csvtojson can help.
Assuming you have node.js, and npm installed, the package can be installed globally.
Once installed, I can use it as a CLI tool to convert .csv to .json
Although the output is a bit messy I more or less have what I want. The JSON ends up being an array of objects, one for each row in the spreadsheet.
csvtojson seems to use the values set in the first cell of each column of a spread sheet as the key values for each object. One way to resolve any situation where one might be getting weird key values is to manually edit the csv file and define whatever values are desired in the first row of the CSV.
There is an option to set header values, but I was not able to get it to work from the command line.