A CSV (or comma-separated value) file is a text file containing data formated as a table. Each line represents a row and contains a list of cell values separated by commas. The first row can optionally contain the list of column names.
An example is shown below:
FirstName,LastName,Company Portia,Mcfann,Beachcomber Realty Andrew,Fenstermacher,Shafer Commercial Seating Inc Brady,Tatum,Cywinski Jackson Bohlin Gracie,Riskalla,Richard A Esq Jessup Helga,Rio,Pony Express
Which when handled correctly represents:
FirstName | LastName | Company |
---|---|---|
Portia | Mcfann | Beachcomber Realty |
Andrew | Fenstermacher | Shafer Commercial Seating Inc |
Brady | Tatum | Cywinski Jackson Bohlin |
Gracie | Riskalla | Richard A Esq Jessup |
Helga | Rio | Pony Express |
CSV files are commonly used as a format of data exchange between applications as they are simple to generate and easily understood by a wide range of software.
Format Details
Within a CSV file the comma character represents a division between two cells (or fields) and the new line character(s) represents a division between two rows (or records). For this reason steps need to be taken to protect these characters if they actually form part of the field data itself.
When a field in a CSV file contains a comma or new line it is simply surrounded by quotes (").
However, what if the cell contains text that itself is surrounded by quotes? In that case the quotes, within the cell are represented as double quotes ("").
The combinations are shown below:
Description | Example |
---|---|
Normal Cell | Cell value |
Cell containing comma | "Cell, with a comma" |
Call containing a new line |
"Cell with a new line" |
Cell containing quoted data | "Cell with some ''''quotes'''' in it" |
An example is shown below:
FirstName,LastName,Company,Address Claude,Piscitello,"Nippard, Lewis Straughn Pa","127 Maple St Madison TN 37115" "Beverley ""long""",Schilk,"Wahl, Travis J Esq","445 Broadway Denver CO 80203" Maude,Balceiro,"Berger, Leslie M Esq","4933 E Colonial Dr Orlando FL 32803" Roger,Voorheis,Park View Guest House,"204 N Guadalupe St Santa Fe NM 87501" Martina,Rissman,Criterion Electronics Inc,"726 Plymouth Park Irving TX 75061"
Which when handled correctly represents:
FirstName | LastName | Company | Address |
---|---|---|---|
Claude | Piscitello | Nippard, Lewis Straughn Pa |
127 Maple St Madison TN 37115 |
Beverley "long" | Schilk | Wahl, Travis J Esq |
445 Broadway Denver CO 80203 |
Maude | Balceiro | Berger, Leslie M Esq |
4933 E Colonial Dr Orlando FL 32803 |
Roger | Voorheis | Park View Guest House |
204 N Guadalupe St Santa Fe NM 87501 |
Martina | Rissman | Criterion Electronics Inc |
726 Plymouth Park Irving TX 75061 |
It's Not All About Commas
Of course commas and quotes do not always need to be the characters used to separate the elements of a CSV file. Some common variations exists, although their use does alter the name as would be expected:
Name | Extension | Field Separator | Field Surround |
---|---|---|---|
Comma-separated value | CSV | Comma (,) | Quote (") |
Pipe separated value | PSV | Pipe (|) | Quote (") |
Tab separated value | TSV | Tab | Quote (") |
In fact almost any characters can be used to separate the rows and fields, depending on the software used to edit the file.
How to Edit CSV Files
Simply download and install Rons Data Edit.