DexNet 4.7.0
Public Member Functions
com::sparsity::dex::io::CSVReader Class Reference

CSVReader interface. More...

Inheritance diagram for com::sparsity::dex::io::CSVReader:
Inheritance graph
Collaboration diagram for com::sparsity::dex::io::CSVReader:
Collaboration graph

List of all members.

Public Member Functions

void SetMultilines (int numExtralines)
 Allows the use of fields with more than one line.
void SetNumLines (int numLines)
 Used to limit the number of lines that will be read.
bool Reset () throws System.IO.IOException
 Moves the reader to the beginning.
void Close () throws System.IO.IOException
 Closes the reader.
void SetStartLine (int startLine)
 Sets the number of lines to be skiped from the beginning.
void Open (System.String f) throws System.IO.IOException
 Opens the source file path.
void SetSeparator (System.String sep) throws System.ApplicationException
 Sets the character used to separate fields in the file.
void SetQuotes (System.String quotes) throws System.ApplicationException
 Sets the character used to quote fields.
void SetSingleLine ()
 Only allows single line fields.
void SetLocale (System.String localeStr)
 Sets the locale that will be used to read the file.
int GetRow () throws System.IO.IOException
 The row number for the current row.
bool Read (com.sparsity.dex.gdb.StringList row) throws System.IO.IOException
 Reads the next row as a string array.
 CSVReader ()
 Constructs CSVReader.

Detailed Description

CSVReader interface.

A very simple CSV reader.

It works as any other RowReader, but open must be called once before the first read operation.

Using the format RFC 4180.

Except: leading and trailing spaces, adjacent to CSV separator character, are trimmed.

You can use your own separators and quote characters. By default the separator is the comma (,) and the quote character is the double quotes (").

Fields with multiple lines can be allowed (and the maximum lines specified), but the default is a single line.

The locale string can be used to set the language, country and the file encoding. The format must be "[language_territory][.codeset]". But only the file encoding is being used in the current version.

The languages supported are: "en_US", "es_ES" and "ca_ES".

The file encodings supported are: "utf8" and "iso88591".

For example:

To don't change the default locales, use an empty string: "".

To read a file in utf8 with the default language settings use ".utf8".

To read a file in iso88591 with English language use: "en_US.iso88591".

Author:
Sparsity Technologies http://www.sparsity-technologies.com

Member Function Documentation

void com::sparsity::dex::io::CSVReader::Close ( ) throws System.IO.IOException

Closes the reader.

Exceptions:
System.IO.IOExceptionIf the close fails.

Reimplemented from com::sparsity::dex::io::RowReader.

int com::sparsity::dex::io::CSVReader::GetRow ( ) throws System.IO.IOException

The row number for the current row.

Returns:
The current row number; 0 if there is no current row.
Exceptions:
System.IO.IOExceptionIf it fails.

Reimplemented from com::sparsity::dex::io::RowReader.

void com::sparsity::dex::io::CSVReader::Open ( System.String  f) throws System.IO.IOException

Opens the source file path.

Parameters:
f[in] CSV file path.
Exceptions:
System.IO.IOExceptionIf bad things happen opening the file.
bool com::sparsity::dex::io::CSVReader::Read ( com.sparsity.dex.gdb.StringList  row) throws System.IO.IOException

Reads the next row as a string array.

Parameters:
row[out] A string list with each comma-separated element as a separate entry.
Returns:
Returns true if a row had been read or false otherwise.
Exceptions:
System.IO.IOExceptionIf bad things happen during the read.

Reimplemented from com::sparsity::dex::io::RowReader.

bool com::sparsity::dex::io::CSVReader::Reset ( ) throws System.IO.IOException

Moves the reader to the beginning.

Restarts the reader.

Returns:
true if the reader can be restarted, false otherwise.
Exceptions:
System.IO.IOExceptionIf bad things happen during the restart.

Reimplemented from com::sparsity::dex::io::RowReader.

void com::sparsity::dex::io::CSVReader::SetLocale ( System.String  localeStr)

Sets the locale that will be used to read the file.

Parameters:
localeStr[in] The locale string for the file encoding.
void com::sparsity::dex::io::CSVReader::SetMultilines ( int  numExtralines)

Allows the use of fields with more than one line.

Parameters:
numExtralines[in] Maximum number of extra lines for each column (0==unlimited, N==N+1 total rows).
void com::sparsity::dex::io::CSVReader::SetNumLines ( int  numLines)

Used to limit the number of lines that will be read.

Parameters:
numLines[in] The maximum number of lines to read (0 == unlimited)
void com::sparsity::dex::io::CSVReader::SetQuotes ( System.String  quotes) throws System.ApplicationException

Sets the character used to quote fields.

Parameters:
quotes[in] Quote character.
Exceptions:
System.ApplicationExceptionnull
void com::sparsity::dex::io::CSVReader::SetSeparator ( System.String  sep) throws System.ApplicationException

Sets the character used to separate fields in the file.

Parameters:
sep[in] Separator character.
Exceptions:
System.ApplicationExceptionnull
void com::sparsity::dex::io::CSVReader::SetStartLine ( int  startLine)

Sets the number of lines to be skiped from the beginning.

Parameters:
startLine[in] The line number to skip for start reading