public final class Csv
extends java.lang.Object
Basic CSV parser. The Csv class provides very basic CSV file parsing
and assumes that CSV files are in a strict format. CSV files are
expected to conform to the following syntax:
- First line contains only the number of rows to be read as an
integer.
- Second line is a strictly comma separated row of type strings, where
each type string has no preceeding or following whitespace. An
example of a type string would be:
int,int,float,char
This type string informs the parser that the rows of the table
have four cells of which the first two are integers and the last
two are floating point numbers. Only three type strings are
supported: 'int', 'float' and 'char'.
- Third line and onwards. These are the table rows. They are expected
to conform to the type format specified in the type line (line 2).
As well as this all rows are expected to have length equal to the
type row. Cells in each row are strictly comma separated and
contain no whitespace. Each cell is expected to be in a format
that Java can parse using parseInt() for integer types,
parseDouble() for floating point types, and char data types are
expected to be a single character optionally enclosed in single
or double quotation marks. An example of several CSV rows which
adhere to the previously given type row:
1,16,3.900,'A'
1,17,2.700,'-'
1,18,2.100,'B'
2,19,4.500,'C'
2,20,1.050,'-'
2,21,0.150,'D'