Excel CSV is a file format used as a portable representation of a database. Each line is one entry or record and the fields in a record are separated by commas.
If field includes a comma or a new line, the whole field must be surrounded with double quotes. When the field is in quotes, any quote literals must be escaped by two quotes (""). Text that comes after quotes that have been closed but come before the next comma will be ignored.
Empty fields are returned as as String of length zero: "". The following line has three empty fields and three non-empty fields in it. There is an empty field on each end, and one in the middle. One token is returned as a space.
,second,, ,fifth,
Blank lines are always ignored. Other lines will be ignored if they start with a comment character as set by the setCommentStart() method.
An example of how CVSLexer might be used:
ExcelCSVParser shredder = new ExcelCSVParser(System.in); String t; while ((t = shredder.nextValue()) != null) { System.out.println("" + shredder.lastLineNumber() + " " + t); }
The CSV that Excel outputs differs from the ISO CSV standard in several respects:
|
|