There is a decent file format for tabular data, and the author dismisses it: parquet. It's compact, encodes all the common data types well, does int/float distinction (thanks for teaching us about how important that is json), stores null records with a mask instead of a special value, row major order, has compression, speedy random access... it has it all. And it isn't bogged down with legacy cruft (yet). Since you n…
parquet is great but it's not particularly easy to read or write. the libraries that do exist to work with it are few and far between, and those that do either have a hundred dependencies or depend on native code (e.g. libarrow). certainly an important dimension in an ideal file format should be the ease of parsing/writing it, and parquet gets an extremely low score on that front imo
Why isn’t there a decent file format for tabular data?
121–130 of 355 posts
Re: Why isn’t there a decent file format for tabular data?
#122Earlier quoted context omitted.
I think CSV is crappy because commas are so common in real data. For almost all scenarios I've had to work with, I'd have been perfectly happy with TSV where literal Tab was a disallowed character. No escaping histrionics required.
I prefer commas because I can see them over tabs. I spend zero time escaping commas because the libraries and read and write with (usually pandas but pretty much everything) escape for me. So unless I’m manually building csvs myself it’s a non-issue and certainly not histrionics.
Re: Why isn’t there a decent file format for tabular data?
#123Parquet is a wonderful file format and is a dream to work with compared to CSV. Parquet embeds the schema in the footer metadata, so the query engines don't need to guess what the column names / data types are. Parquet used to be poorly supported, but now it's well supported by almost all languages. You can even view Parquet files in text editors now, but that's not something I've ever needed ( https://blog.jetbrains…
For context, this would be for an application that passes sqlite files around. So naturally it has good support for the database level of storage. But parquet is so fast for some applications as well as so compressed.
Re: Why isn’t there a decent file format for tabular data?
#124Earlier quoted context omitted.
> Removing the ability to embed record delimiters, for example, means you can process the records in parallel. That’s a massive improvement all by itself. I can process records from a csv in parallel just fine. Lexing isn't slow. .csv stream -> tokens -> records (-> aggregate into ~100ms blocks) -> work queue with N workers
You lex the whole file, separate it into records and then process them? Doesn’t sound like you’re processing the file in parallel to me. TFA’s way would allow you to start at any arbitrary file position, just advance until you find a record separator then start parsing from there without having to worry about starting in the middle of a quoted string.
Re: Why isn’t there a decent file format for tabular data?
#125Earlier quoted context omitted.
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 an…
> If you don't, then split each line on ",". Problem solved. And the millionth bad CSV parser is born.
Re: Why isn’t there a decent file format for tabular data?
#126csv -- Simple for simple use cases, text-based, however many edge cases, feature lacking etc
xlsx -- Works in excel, ubiquitous format with a standard, however complicated and missing scientific features
sqlite -- Designed for relational data, somewhat ubiquitous, types defined but not enforced
parquet / hdf5 / apache feather / etc -- Designed for scientific use cases, robust, efficient, less ubiquitous
capn proto, prototype buffers, avro, thrift -- Has specific features for data communication between systems
xml -- Useful if you are programming in early 2000s
GDBM, Kyoto Cabinet, etc -- Useful if you are programming in late 1990s
Pick your poison I guess. Engineering is about trade offs.
Re: Why isn’t there a decent file format for tabular data?
#127HDF5 is often used in scientific computing for this. https://en.wikipedia.org/wiki/Hierarchical_Data_Format
You can just use sqlite then. Very compact, highly popular (in different role though). Seen it used for large datasets - map tiles (millions of jpeg files). Much smaller size than zip or tar archive, indexed, fast. P.S. sqlite> .mode csv sqlite> .import city.csv cities
Re: Why isn’t there a decent file format for tabular data?
#128> difficult to parse efficiently using multiple cores, due to the quoting (you can’t start parsing from part way through a file).
But I do not see why this is the case.
Step 1: loop over file (in parallel) to determine indices of quote characters
Step 2: loop over indices outside quote regions (in parallel) to determine indices of comma and return characters
Step 3: return two dimensional integer array with pointers to cells of table
Re: Why isn’t there a decent file format for tabular data?
#129Seems like the problem here is there is several high quality and well-developed formats, but the author and the commenters here dismiss them because of the different trade-offs they make. csv -- Simple for simple use cases, text-based, however many edge cases, feature lacking etc xlsx -- Works in excel, ubiquitous format with a standard, however complicated and missing scientific features sqlite -- Designed for relat…
Re: Why isn’t there a decent file format for tabular data?
#130Hope this article makes them more popular.