CSV format

There is no formal definition of the CSV format, or at least none that everyone agree to, so different applications have slightly different ideas about the look of such a file. CSV Touch tries to handle as many of those as possible, but it can be a little bit difficult finding out what the problem is if your file doesn’t seem to work.

GENERAL RULES

Before showing some examples, here are a couple of general rules for acceptable files:

  1. The first line should contain the column titles; they must all be different
  2. Use quotation marks (“) around a whole text entry if there are quotation marks inside the text entry itself (explaining example below)
  3. Use quotation marks around a whole entry if the entry contains the delimiter (e.g. a comma) for the file
  4. No line breaks are accepted, even if the line break is inside quotation marks
  5. All rows should contain the same number of items
  6. Max 64 columns and 65536 characters in one single row; no row limit except for the global memory limitation for an application (how many rows this means in real life depends on how long they are; normally thousands of lines is not a problem)

Almost all applications which can export CSV files will automatically produce files fulfilling these rules, so it is rare that you need to know about them.

There is a setting for Alternative Parsing in the preferences. If this is set to ON, files will be parsed (i.e. investigated for entries, line breaks etc.) in another way which is normally more lenient in the files accepted. This means that Rule 2, 4, 6 above no longer applies; if you have line breaks between quotation marks, this is OK; if you have quotation marks only inside a text entry itself, this is OK; any number of columns/characters (up to what your device can manage) is OK. However, this alternative parsing behaves slightly different in other situations as well, so try which one is better for your files.

GOOD FILES

1.

"Author","Title",Price,"Copies","Part of...",Number,Category,Created
"Abbott,E","Flatland",100,1,,,Novel,02/12/1991
"Abell,E","Exploration of the Universe, 2nd Ed.",175,1,,,Physics,02/12/1991

Note that it is OK to have quotation marks around some entries, but not around others (“Author” compared to Physics). However, it is necessary to use them for “Abbot,E” since there is a “,” inside the text entry (Rule 3 above).

2.

Title;Plattform;Price;Bought
Advance Wars;GBA;125;15/11/2002
Advance Wars: Dual Strike;DS;328;

Note that it is not necessary to have quotation marks here since there are no “;” inside the text entries. Also note the trailing “;” in the last row which is necessary to indicate that the data in the last column (“Bought”) is empty for this row (Rule 5 above).

BAD FILES

1.

Title,Length,Language
Three Amigos,99,English
Lindsay Anderson's "if...",129,English

The problem here is the last row which uses quotation marks inside the text entry in the first column (Rule 2). The correct row to make sure that the text entry appears with quotation marks around the word if…:

"Lindsay Anderson's ""if...""",129,English

(There is a setting, Keep Quotes, which would make this example work OK, but for almost all files using Keep Quotes will lead to errors.)

2.

"Austen,J",Emma,"2007"
"Austen,J","Pride and Prejudice",2006,19th century

Here there are two problems. The first is the fact there are no column titles, i.e. an initial row with those is missing (Rule 1 above):

Author,Novel,Year,Notes

The second problem is in the “Emma” row. There are no notes for this novel, but to indicate this the row needs a terminating “,” to make all the rows have the same number of items (Rule 5):

"Austen,J",Emma,"2007",

3.

Actor/Actress|Line|Movie
"Clark Gable"|"Frankly, my dear,
I don't give a damn!"|"Gone With the Wind"

Here the problem is the line break inside Clark Gable’s line; it is inside quotation marks but this is still illegal (Rule 4). Correct version:

"Clark Gable"|"Frankly, my dear, I don't give a damn!"|"Gone With the Wind"