Live data from Hacker News

Why isn’t there a decent file format for tabular data?

successfulsoftware.net

41–50 of 355 posts

Re: Why isn’t there a decent file format for tabular data?

#41

I literally don't get why JSON is bad: [{row1}, {row2}, {row3}] The fact that it can do more is in no way a negative. Can even make a limited JSON parser with reduced capabilities. And with JSON can do more definitions like header names vs column names vs just arrays of arrays.

Doesn’t open in Excel.

And since it doesn’t require one record per line it can be a hassle to read without having to parse it.

It’s really nice to be able to do “head -n 5”

Re: Why isn’t there a decent file format for tabular data?

#42

I literally don't get why JSON is bad: [{row1}, {row2}, {row3}] The fact that it can do more is in no way a negative. Can even make a limited JSON parser with reduced capabilities. And with JSON can do more definitions like header names vs column names vs just arrays of arrays.

This table has one column, one row, and thus one cell. What is its value?

[{"col1":"val1", "col1":"val2"}]

Re: Why isn’t there a decent file format for tabular data?

#43
post #19

> No escaping. If you want to put \u001F or \u001E in your data – tough you > can’t. Use a different format. > It would be reasonably compact, efficient to parse and easy to manually edit > (Notepad++ shows the unit separator as a ‘US’ symbol). Is it me or it won't be human readable because of the lack of new lines?

I rarely want to see tabular data in a human-readable format. It is always the most tedious way to approach it. My go-to is Excel/LibreOffice Calc. This approach is at least tolerable to edit in a text editor, while something like the OpenDocument Spreadsheet format or the Excel format is impenetrable.

I rarely do it, but it’s nice to be able to Human read when I need to. Also being able to use all the command line text tools is super convenient.

I think it’s a think where having the option for the .1% of times when you need it keeps me using it.

Re: Why isn’t there a decent file format for tabular data?

#44

I literally don't get why JSON is bad: [{row1}, {row2}, {row3}] The fact that it can do more is in no way a negative. Can even make a limited JSON parser with reduced capabilities. And with JSON can do more definitions like header names vs column names vs just arrays of arrays.

Not being able to do more is exactly the point. By restricting the space of the file format, we can free the mind to think about how to fit the data to the format.

If you can do anything, it becomes hard to do the right thing. If you can only do the right thing, it becomes trivial to decide.

Re: Why isn’t there a decent file format for tabular data?

#45

I literally don't get why JSON is bad: [{row1}, {row2}, {row3}] The fact that it can do more is in no way a negative. Can even make a limited JSON parser with reduced capabilities. And with JSON can do more definitions like header names vs column names vs just arrays of arrays.

The repetition of the keys seems like the sore point here.

I could see a specialized form of JSON using jagged arrays

    {"Header": ["Name", "Street Address", "City"]
    "Body": [
      ["Alice", "123 Fake St", "Faketon"],
      ["Bob", "987 Any Pl", "Anytown"],
    ]}
in that way the keys aren't repeated. It wouldn't be coherent useful JS objects when deserialized, but it would be trivial to convert js table object into a true array of Javascript objects.

Re: Why isn’t there a decent file format for tabular data?

#46

if you are ok with a binary format there is apache parquet or apache feather or 'jay' ( https://datatable.readthedocs.io/en/latest/api/frame/to_jay.... ).

No doubt binary formats like Parquet are the way to go for high performance with multi-GB datasets. Seems like total overkill if you have a few hundred or thousand rows of data though. Being able to create/edit/view stuff in a text editor and easily version it is very useful.

Do people really edit csvs in a text editor? It's horrific, the columns don't line up at all, empty cells are represented by a bunch of commas in a row (which, are you supposed to count all the commas?)

And in terms of versioning, I have seen people commit diffs of csvs before, and they're equally unreadable.

CSV is a plain text format, but that basically buys you nothing. As long as you're going to be loading it into excel or whatever anyway, might as well just pick a good binary format like parquet.

Re: Why isn’t there a decent file format for tabular data?

#47
post #33

Earlier quoted context omitted.

it will also be at least 2x bigger on disk for no reason.

Your data must be very sparse or include a lot of escape chars for that. I've seen a lot of CSV where everything is quoted, meaning that the cell separator is effectively "," which is only one character less than and still beats the pants off of JSON or XML. imho, it would be a good compromise, in that there's already partial tooling and GUI support.

But usually it will be 1 character vs 4. So that adds a lot of space that doesn’t add much value.

It’s also harder to read.

Re: Why isn’t there a decent file format for tabular data?

#48
post #9

If it's tabular, I want schema for the columns. Is this column a 'number' or a string? Even better, is there a max length or precision known? Can the cell be null and how is that represented? How are dates formatted? Are they UTC/specific TZ, etc. Most of my complaints about CSV relate to trying to determine the types used to parse or import as, not how commas are escaped. Excel, for example, actually warns you about…

Mostly the problem comes from how excel is apocalyptically shitty at inferring datatypes, incorrectly assuming non-dates are dates and ISO8601 dates are god knows what, when a sane format would default to text if it didn't know better.

Re: Why isn’t there a decent file format for tabular data?

#49
post #23

I literally don't get why JSON is bad: [{row1}, {row2}, {row3}] The fact that it can do more is in no way a negative. Can even make a limited JSON parser with reduced capabilities. And with JSON can do more definitions like header names vs column names vs just arrays of arrays.

Doesn't have a great int64 number story, no native dates / date-times. If you want named tuples, then the names need to go everywhere, otherwise it's a serialization mechanism on top of JSON.

Number size is out of JSON scope, int64 is a problem of JavaScript no matter what format you use.

Re: Why isn’t there a decent file format for tabular data?

#50
post #38

I think it’s because csv is good enough. All the standards I’ve seen haven’t been worth the effort to implement. So since csv, with all its flaws, is good enough it crowds out other open standards. People complain about it, but it’s not really much of a challenge to use csv. I’d also prefer it over the crap (rdf, xml, even schemad json) proposed by people who value more structure. It’s easier for me to just make clea…

CSV is fine. If you care about edge cases, implement RFC 4180:

https://www.rfc-archive.org/getrfc.php?rfc=4180

If you don't, then split each line on ",". Problem solved.

If you find tab delimited easier to read (as I do), then check out the IANA spec for TSV files:

https://www.iana.org/assignments/media-types/text/tab-separa...

It's easier to parse than CSV. Unfortunately, you have to decide how to handle newlines and tabs yourself (probably as \n, \t, with \\ for backslashes).

Post reply on HN