Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to CSV?

I intend to build a RESTful service which will return a custom text format. Given my very large volumes of data, XML/JSON is too verbose. I'm looking for a row based text format.

CSV is an obvious candidate. I'm however wondering if there isn't something better out there. The only I've found through a bit of research is CTX and Fielded Text.

I'm looking for a format which offers the following:

  • Plain text, easy to read
  • very easy to parse by most software platforms
  • column definition can change without requiring changes in software clients

Fielded text is looking pretty good and I could definitely build a specification myself, but I'm curious to know what others have done given that this must be a very old problem. It's surprising that there isn't a better standard out there.

What suggestions do you have?

like image 485
srmark Avatar asked Oct 06 '10 16:10

srmark


People also ask

What is better than CSV files?

Feather is the fastest to read and write. It takes about half the time CSVs take to load. Even Pickle files are significantly slower compared to Feather. Again, JSONs take too much time to load into the memory because it takes large disk storage space. Feather is far better than CSV on writing performance too.

Is CSV or XML better?

CSV is considered a flat structure of data format. It is highly convenient because it requires fewer technical skills and you can access files of this format with most applications. Additionally, CSV is significantly smaller than XML, requiring less processing power.

Is JSON better than CSV?

More specifically, JSON is preferred for API use, which prioritizes file size due to its lightweight feature. JSON is also praised for its ability to be easily converted into other formats. JSON conversion tools are quite common, and there are many free JSON to CSV format conversion tools out there.

Why are Parquet files better than CSV?

Parquet files are easier to work with because they are supported by so many different projects. Parquet stores the file schema in the file metadata. CSV files don't store file metadata, so readers need to either be supplied with the schema or the schema needs to be inferred.


1 Answers

Looking through the existing answers, most struck me as a bit dated. Especially in terms of 'big data', noteworthy alternatives to CSV include:

  • ORC : 'Optimised Row Columnar' uses row storage, useful in Python/Pandas. Originated in HIVE, optimised by Hortonworks. Schema is in the footer. The Wikipedia entry is currently quite terse https://en.wikipedia.org/wiki/Apache_ORC but Apache has a lot of detail.

  • Parquet : Similarly column-based, with similar compression. Often used with Cloudera Impala.

  • Avro : from Apache Hadoop. Row-based, but uses a Json schema. Less capable support in Pandas. Often found in Apache Kafka clusters.

All are splittable, all are inscrutable to people, all describe their content with a schema, and all work with Hadoop. The column-based formats are considered best where cumulated data are read often; with multiple writes, Avro may be more suited. See e.g. https://www.datanami.com/2018/05/16/big-data-file-formats-demystified/

Compression of the column formats can use SNAPPY (faster) or GZIP (slower but more compression).

You may also want to look into Protocol Buffers, Pickle (Python-specific) and Feather (for fast communication between Python and R).

like image 52
Jo van Schalkwyk Avatar answered Sep 29 '22 06:09

Jo van Schalkwyk