Inviwo  0.9.10.1
Inviwo documentation
inviwo::CSVReader Class Reference

A reader for comma separated value (CSV) files with customizable delimiters. The default delimiter is ',' and headers are included. More...

#include <csvreader.h>

+ Inheritance diagram for inviwo::CSVReader:

Public Member Functions

 CSVReader (const CSVReader &)=default
 
 CSVReader (CSVReader &&) noexcept=default
 
CSVReaderoperator= (const CSVReader &)=default
 
CSVReaderoperator= (CSVReader &&) noexcept=default
 
virtual CSVReaderclone () const override
 
void setDelimiters (const std::string &delim)
 
void setFirstRowHeader (bool hasHeader)
 
virtual std::shared_ptr< DataFramereadData (const std::string &fileName) override
 
std::shared_ptr< DataFramereadData (std::istream &stream) const
 
- Public Member Functions inherited from inviwo::DataReaderType< DataFrame >
 DataReaderType (const DataReaderType &rhs)=default
 
 DataReaderType (DataReaderType &&rhs) noexcept=default
 
DataReaderTypeoperator= (const DataReaderType &that)=default
 
DataReaderTypeoperator= (DataReaderType &&that) noexcept=default
 
virtual std::shared_ptr< DataFramereadData (const std::string &filePath, MetaDataOwner *)
 
- Public Member Functions inherited from inviwo::DataReader
 DataReader (const DataReader &rhs)=default
 
 DataReader (DataReader &&rhs) noexcept=default
 
DataReaderoperator= (const DataReader &that)=default
 
DataReaderoperator= (DataReader &&that) noexcept=default
 
const std::vector< FileExtension > & getExtensions () const
 
void addExtension (FileExtension ext)
 

Detailed Description

A reader for comma separated value (CSV) files with customizable delimiters. The default delimiter is ',' and headers are included.

Member Function Documentation

◆ readData() [1/2]

std::shared_ptr< DataFrame > inviwo::CSVReader::readData ( const std::string &  fileName)
overridevirtual

read a CSV file from a file

Parameters
fileNamename of the input CSV file
Returns
a DataFrame containing the CSV data
Exceptions
FileExceptionif the file cannot be accessed
CSVDataReaderExceptionif the file contains no data, the first row should hold column headers, but they cannot be found, or if there are unmatched quotes at the end of the file

Implements inviwo::DataReaderType< DataFrame >.

◆ readData() [2/2]

std::shared_ptr< DataFrame > inviwo::CSVReader::readData ( std::istream &  stream) const

read a CSV file from a input stream, e.g. a std::ifstream. In case file streams are used, the file must have be opened prior calling this function.

Parameters
streaminput stream with the CSV data
Returns
a DataFrame containing the CSV data
Exceptions
CSVDataReaderExceptionif the given stream is in a bad state, the stream contains no data, the first row should hold column headers, but they cannot be found, or if there are unmateched quotes at the end of the stream

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