I'm planning to collect some data over a few months (daily) for further processing and representation in JavaScipt (probably using any js libraries, such as d3.js, etc. I don't know which one yet). The data will consist of:
- date
- one integer
- one decimal number
Which file/data format would you recommend for recording data for subsequent work with JavaScript?
I think CSV would be more appropriate here because it sounds like it's just going to be a big long list of datapoints.
JSON would work, just like XML or any other system would work, but as much as I love JSON, it is not necessarily well-suited to the job:
JSON will be space-inefficient. It requires lots of punctuation characters.
JSON will be memory-inefficient. To add anything to the JSON file you'll need to:
CSV requires much less superfluous punctuation, and you can append a new line of data to the end of your file without needing to read and write the entire thing.
Consider:
JSON (not pretty):
JSON (pretty):
CSV:
Javascript doesn't have a built-in CSV parser in the way it has
JSON.parse... because parsing CSV is really easy! Here's just one of many ways of doing it: