CSVJ

CSVJ is a csv-like format for storing tables that follows certain JSON encoding rules.

Unlike plain csv, CSVJ has a strict definition for separators, quoting, encoding and non-optional header line.

Why?

There are many problems with CSV format, mainly text-encoding, separators and delimiters.

You can't be sure that something called 'CSV' generated in one application could be imported to another without tweaking export or import parameters. CSVJ solves this.

Format

CSVJ file consists of number of lines:

newline is \n or \r\n

Each CSVJ line is like a JSON array, except:

Obviously CSVJ line itself can never contain \r or \n symbols — or it becomes two lines. These symbols are escaped in strings.

String and number formats are the same as JSON.

First line of every CSVJ file must contain table header — human readable names corresponding to the columns in the file, always represented as strings.

Table header cannot be ommited. When there are absolutely no information about table columns available, an empty first line can be used.

Like JSON, CSVJ files should be encoded in UTF-8 and should not include byte order mark (see RFC 8259 section 8.1 about JSON)

Example

Consider the following table:

Year Make Model Description Price
1996 Ford Ka abs, ac 3000
1998 Chevy Venture "Extended Edition" 3999
1998 Chevy Venture "Executive Edition, Large" 4999
1995 Jeep Grand Cherokee SELL NOW!
air, moon roof, loaded
$3599

The table above represented in CSVJ will look the following way:

"Year","Make","Model","Description","Price"
1996,"Ford","Ka","abs,ac",3000
1998,"Chevy","Venture \"Extended Edition\"","",3999
1998,"Chevy","Venture \"Executive Edition, Large\"","",4999
1995,"Jeep","Grand Cherokee","SELL NOW!\nair, moon roof, loaded","$3599"

The representation does not change, regardless preferred decimal or value separators of the country the code is running in.

Frequently Asked Questions

What's wrong with CSV RFC 4180 ? Unfortunately by the time that informational memo about CSV files appeared there were many existing CSV implementations that work differently. Many of them are not compliant with RFC 4180 and do not indent to be. How should my application parse null? Preferably null should be represented as null-value, or #N/A error value.
If the application does not support absence of values, it should be represented as an empty string.
What does CSVJ stands for? Is it acronym? CSVJ is not an acronym. It just rather unique combination of letters which is relatively unused as a data format or library name (as of April 2018). The name implies strong relation to CSV and some relation to JSON. Is CSVJ file a valid CSV file? Sometimes it is. If your string values do not have any escaped characters (newlines, double quotes, etc) — it might be parsed as CSV file in some applications.
For the sake of transparency, we recommend specifying that you are exporting CSVJ file, when you are exporting CSVJ file.

Libraries and Software

See github.com/csvj-org for all code by CSVJ.org. Following libraries are available:

Looking for volunteers: we want to create CSVJ libraries for different languages including, but not limited to: C#, C++, golang, Java, JavaScript, Matlab, Objective-C, PHP, Python, R, rust, Swift.

Other languages are welcome too. Email rcpt at andrian dot io with csvj mentioned in the subject.

After libraries are created, we would like the following types software to support CSVJ: RDBMS, spreadsheet editors, statistical software, financal and accounting software, machine learning packages and solutions, user management systems and others.

Metadata

CSVJ files must have .csvj extension, so user could destinct them from broken CSV files.

Currently there is no registered MIME extension, however we plan to apply for text/csvj at some point.

Because CSVJ files are plain text, you are free to use text/plain MIME type as long as .csvj extension is preserved.

License

All original content at csvj.org is distributed under MIT license:

Copyright (c) 2018 CSVJ.org

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Some images from json.org are used according to JSON license:

Copyright (c) 2002 JSON.org

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The Software shall be used for Good, not Evil.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.