Overview     Modules     Class Hierarchy     Classes     Members  
tlp::CSVSimpleParser Class Reference

Parse a csv data and send each tokens to the given CSVContentHandler object. More...

#include <CSVParser.h>

Inheritance diagram for tlp::CSVSimpleParser:
Collaboration diagram for tlp::CSVSimpleParser:

List of all members.

Public Member Functions

Protected Member Functions

  • virtual std::string treatToken (const std::string &token, int row, int column)

Detailed Description

Parse a csv data and send each tokens to the given CSVContentHandler object.

Parse a csv data and send each tokens to the given CSVContentHandler object. Get each line of the file in the given range and parse them. This object skip empty lines. Send the found tokens to the CSVContentHandler interface.

 CSVParser parser(fileName,";","\"","UTF-8",true);
 \/\/Automatically remove quotes.
 CSVContentHandler * handler ;
 parser.parse(handler);

Constructor & Destructor Documentation

tlp::CSVSimpleParser::CSVSimpleParser ( const std::string &  fileName,
const std::string &  separator = std::string(";"),
char  textDelimiter = '"',
const std::string &  fileEncoding = std::string("UTF-8"),
unsigned int  firstLine = 0,
unsigned int  lastLine = UINT_MAX 
)

Construct a csv simple file parser.

Parameters:
filenameThe path to the file to import.
separatorThe separator to use.
textDelimiterIf a token is sourrounded by this charater we ignore all the separators found in this token. Useful if a token contains the separator.
firstLineThe number of the first line to read. The first line is 0.
lastLineThe number of the last line to read.
virtual tlp::CSVSimpleParser::~CSVSimpleParser ( ) [virtual]

Member Function Documentation

std::string tlp::CSVSimpleParser::fileEncoding ( ) const [inline]
std::string tlp::CSVSimpleParser::fileName ( ) const [inline]
bool tlp::CSVSimpleParser::parse ( CSVContentHandler handler,
tlp::PluginProgress *  progress = NULL 
) [virtual]

Parse the data and send the tokens found to the CSVContentHandler.

Notify the progression of the parsing with the progress object.

Implements tlp::CSVParser.

std::string tlp::CSVSimpleParser::separator ( ) const [inline]
void tlp::CSVSimpleParser::setFileEncoding ( const std::string &  fileEncoding) [inline]
void tlp::CSVSimpleParser::setFileName ( const std::string &  fileName) [inline]
void tlp::CSVSimpleParser::setSeparator ( const std::string &  separator) [inline]
void tlp::CSVSimpleParser::setTextDelimiter ( char  delimiter) [inline]
char tlp::CSVSimpleParser::textDelimiter ( ) const [inline]
virtual std::string tlp::CSVSimpleParser::treatToken ( const std::string &  token,
int  row,
int  column 
) [protected, virtual]


Tulip Software by LaBRI Visualization Team    2001 - 2012