A CSV Primer
Monday, 14 January 2008 00:00

One of the most common file formats for exchanging data has been the Comma Separated Value (CSV) format. These files are plain text files used to store a table of data. Overall, it is similar to how data would be saved in a spreadsheet, using commas and newlines to help separate data into columns and rows.

To learn the CSV format, it is easiest to look at an example:

First Name,Last Name,E-mail,Date
John,Doe, This e-mail address is being protected from spambots. You need JavaScript enabled to view it ,1/3/2008
Jane,Dough, This e-mail address is being protected from spambots. You need JavaScript enabled to view it ,"Monday, Jan 3rd"
Mary,Jane,,"She says ""Soon"""

Although there isn't an official standard for CSV, the following guidelines are generally accepted:

  • Fields (or cells) of data are separated by comma.
  • Rows of data are separated by a newline.
  • The first row of data generally has the headers, but this is not always necessary.
  • If a comma is part of your data, you must place double quotes around the data (i.e. the character: "). This ensures that the comma is not mistaken as a new field.
  • You may place double quotes around a field, even if there is no comma.
  • If you need double quotes inside a field that is wrapped with double quotes, you must place two of them in a row.
  • Do not place a space before or after the commas, or these can be interpreted as part of the data.
  • If a certain field of data is blank, you can place two commas next to each other to indicate the empty field.
  • Generally, each row of data should have the same number of fields.

 

Data Jelly

Data Jelly is able to import or export files in the CSV format. Aditionally, you may specify characters other than a comma or newline to separate your fields. For example, sometimes the pipe character (|) is used rather than a comma.

Excel

Note that Excel is able to open and save CSV files, but you run the risk of corrupting your data. Excel will sometimes try to auto-format your data, and may mistakenly convert text to a date or remove leading zeroes from a zip code. Using Excel can simplify the editing of your files, but you may need to open the file with a text editor to verify the data is valid.

Further Reading

http://en.wikipedia.org/wiki/Comma-separated_values

http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm

http://edoceo.com/utilitas/csv-file-format