This is valid JSON
[["bob", "jones", 1, 22],
["frank", "was", 32, 45]]
That's unreadable and unparsable by a human?Not only is JSON often more parsable, because it's structured it also becomes a lot easier to query.
I grep and awk xml and json stuff all the time. I also have the added bonus of being able to use `jq` for json content.
When someone says "Maybe we can fix CSV" this is what you should do instead of trying to "fix" CSV.
Yeah, it's never really come up as it's generally trivial to convert into this format from either a text editor or sed (Look for the `],[` and put a new line after the comma).
[[1,2,3],
[4,5,6]]
It's easy to make a structured data interchange format mimic and unstructured format. It's impossible to go the other way around without severe problems.If the primary usecase is to take data give it to a non-programmer to evaluate it, then CSV isn't terrible. Add a transformer that's ran when someone manually requests to see the data.
However, for machine to machine communication, CSV should never be used.
I feel so much of what keeps CSV in use is that it's a format that you can relatively easily generate without pulling in a lot of library dependencies and relatively quickly generate something that users can just "double click it opens in Excel".
What the Excel team could really gift to developer humanity at this point is some dumb file extension Excel registers like XLJSON that you could just rename a JSON file to and Excel opens it like a spreadsheet on double click.
What's ensuring the format of data in a CSV file?
Format comes from the same place it comes from for CSV. It's part of whatever data contract you are making with whatever system is providing the data. If someone shoves YAML into a Json file you've got problems, just like you have problems if someone starts talking about cars when you expected a file about airplanes.
At some point, you've got to turn file data into application data regardless of format. CSV offers no help in shaping the data and has a bunch of footguns to boot.
> JSON is one of the formats Pandas can read, but it has to be structured in a format the python library can read in as tabular data.
Pandas is highly flexible in it's ability to read in Json data, What I showed would be trivially loadable by Pandas, so would other formats (including more traditional JSON data).
Turning structured data into tabular data is trivial. What isn't trivial is turning tabular data into structured data.