libdballe  7.6
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
dballe::CSVReader Class Reference
Inheritance diagram for dballe::CSVReader:
dballe::memdb::serialize::CSVInfile dballe::memdb::serialize::CSVValueStorageInfile< memdb::Stations > dballe::memdb::serialize::CSVValueStorageInfile< memdb::StationValues > dballe::memdb::serialize::CSVValueStorageInfile< memdb::Values > dballe::memdb::serialize::CSVValueStorageInfile< VALUES > dballe::memdb::serialize::CSVStationsInfile dballe::memdb::serialize::CSVStationValuesInfile dballe::memdb::serialize::CSVValuesInfile

Public Member Functions

 CSVReader (std::istream &in)
 
 CSVReader (const std::string &pathname)
 
void open (const std::string &pathname)
 Open the given file and sets close_on_exit to true.
 
void close ()
 Sets in to 0. More...
 
int as_int (unsigned col) const
 Return the given column, as an integer. More...
 
int as_int_withmissing (unsigned col) const
 Return the given column, as an integer. More...
 
wreport::Varcode as_varcode (unsigned col) const
 Return the given column, as a Varcode. More...
 
bool move_to_data (unsigned number_col=0)
 Find the first line where the given column exists and starts with a number. More...
 
bool next ()
 Read the next CSV line, returning false if EOF is reached.
 

Static Public Member Functions

static std::string unescape (const std::string &csvstr)
 

Data Fields

bool close_on_exit
 If true, the input stream will be deleted upon destruction. More...
 
std::string line
 Last line read.
 
std::vector< std::string > cols
 Parsed CSV columns for the last line read.
 

Protected Member Functions

int next_char ()
 

Protected Attributes

std::istream * in
 

Member Function Documentation

int dballe::CSVReader::as_int ( unsigned  col) const

Return the given column, as an integer.

A missing value raises an exception.

int dballe::CSVReader::as_int_withmissing ( unsigned  col) const

Return the given column, as an integer.

A missing value is returned as MISSING_INT.

wreport::Varcode dballe::CSVReader::as_varcode ( unsigned  col) const

Return the given column, as a Varcode.

A missing value raises an exception.

void dballe::CSVReader::close ( )

Sets in to 0.

If close_on_exit is true, close the currently opened file.

bool dballe::CSVReader::move_to_data ( unsigned  number_col = 0)

Find the first line where the given column exists and starts with a number.

This can be used to skip titles and empty lines, moving to the start of the real data. Real data is identified by using a column that starts with text in the headers and number in the data.

Returns
true if a data line has been found, false if we reached EOF

Field Documentation

bool dballe::CSVReader::close_on_exit

If true, the input stream will be deleted upon destruction.

If false, it will be left alone.


The documentation for this class was generated from the following file: