Sunday, September 21, 2014

Comma Separated Values (CSV)

Comma Separated Values (CSV) file format is used to present tabular data in a plain text format.  The first line is like a header column informing the field/column names in each record seen on the succeeding rows. Each line after the first in a csv text is a record that is separated from other records with line breaks. Those records have fields or field values separated by a comma (,). The format is quite popular as a means of transferring tabular data between different applications.

CSV example
Id,Product Name,Price
1,Sailor Hat,$5
2,Old Rod,$50
3,Waffle Maker,$120

Many programming languages have ways to parse the format. Java has several libraries for CSV including openscv. Meanwhile, Microsoft's dot Net framework (.Net) has Csv Reader and a built in parser class that can be set for a csv format. PHP even has a function built in for csv fgetcsv().  Technically, any programming language that has I/O support can read and write csv files. It's just plain text and not binaries.

There are other formats for representing data in plain text including JSON and XML. However, it seems that not all JSON or XML content can be read by spreadsheets applications. JSON and xml are not confined to a tabular representation of data. The tabular separation makes csv simple to generate from a database management system or DBMS.

Spreadsheet applications such as Microsoft Excel can read and write csv files natively. Those csv files can also be read and written by the spreadsheet application of LibreOffice. Furthermore, spreadsheet applications are often used to read csv files generated from database management systems. 

Reference
EdoCeo. "Comma Separated Values (CSV) Standard File Format." n.d. Edoceo. 2014 .
Microsoft. "Import or export text (.txt or .csv) files." 2006. Office. 2014 .
Networking Group. "Common Format and MIME Type for CSV Files." October 2005. 2014 .


Csv and Json can represent tabular data so they are interchangeable in some cases
There is a CSV to JSON converter here http://formatdelimeters.azurewebsites.net/ thought it's just an Azure website that can be taken down anytime

No comments:

Post a Comment