Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | Private Attributes | List of all members
CsvFile Class Reference

This class handles csv files. Currently only loading is implemented. More...

#include <OpenMS/FORMAT/CsvFile.h>

Inheritance diagram for CsvFile:
TextFile StringList

Public Member Functions

 CsvFile ()
 Default constructor. More...
 
virtual ~CsvFile ()
 destructor More...
 
 CsvFile (const String &filename, char is= ',', bool ie=false, Int first_n=-1)
 Constructor with filename. More...
 
void fload (const String &filename, char is= ',', bool ie=false, Int first_n=-1)
 Loads data from a text file. More...
 
bool getRow (Size row, StringList &list)
 writes all items from a row to list More...
 
- Public Member Functions inherited from TextFile
 TextFile ()
 Default constructor. More...
 
virtual ~TextFile ()
 destructor More...
 
 TextFile (const String &filename, bool trim_lines=false, Int first_n=-1)
 Constructor with filename. More...
 
void load (const String &filename, bool trim_lines=false, Int first_n=-1)
 Loads data from a text file. More...
 
void store (const String &filename)
 Writes the data to a file. More...
 
- Public Member Functions inherited from StringList
template<typename StringType >
StringListoperator<< (const StringType &string)
 Operator for appending entries with less code. More...
 
bool contains (const String &s) const
 Returns if a string is contained in the list. More...
 
void toUpper ()
 Transforms all contained strings to upper case. More...
 
void toLower ()
 Transforms all contained strings to lower case. More...
 
String concatenate (const String &glue="") const
 Concatenate the string elements and putting the glue string between elements. More...
 
 StringList ()
 Default constructor. More...
 
 StringList (const StringList &rhs)
 Copy constructor. More...
 
 StringList (const std::vector< String > &rhs)
 Constructor from vector<String> More...
 
 StringList (const std::vector< std::string > &rhs)
 Constructor from vector<string> More...
 
 StringList (const QStringList &rhs)
 Constructor from QStringList. More...
 
StringListoperator= (const StringList &rhs)
 Assignment operator. More...
 
StringListoperator= (const std::vector< String > &rhs)
 Assignment operator from vector<String> More...
 
StringListoperator= (const std::vector< std::string > &rhs)
 Assignment operator vector<string> More...
 
Iterator search (const Iterator &start, const String &text, bool trim=false)
 Searches for the first line that starts with text beginning at line start. More...
 
Iterator search (const String &text, bool trim=false)
 Searches for the first line that starts with text. More...
 
Iterator searchSuffix (const Iterator &start, const String &text, bool trim=false)
 Searches for the first line that ends with text beginning at line start. More...
 
Iterator searchSuffix (const String &text, bool trim=false)
 Searches for the first line that ends with text. More...
 
ConstIterator search (const ConstIterator &start, const String &text, bool trim=false) const
 Searches for the first line that starts with text beginning at line start. More...
 
ConstIterator search (const String &text, bool trim=false) const
 Searches for the first line that starts with text. More...
 
ConstIterator searchSuffix (const ConstIterator &start, const String &text, bool trim=false) const
 Searches for the first line that ends with text beginning at line start. More...
 
ConstIterator searchSuffix (const String &text, bool trim=false) const
 Searches for the first line that ends with text. More...
 

Private Attributes

char itemseperator_
 
bool itemenclosed_
 

Additional Inherited Members

- Public Types inherited from StringList
typedef iterator Iterator
 Mutable iterator. More...
 
typedef const_iterator ConstIterator
 Non-mutable iterator. More...
 
typedef reverse_iterator ReverseIterator
 Mutable reverse iterator. More...
 
typedef const_reverse_iterator ConstReverseIterator
 Non-mutable reverse iterator. More...
 
- Static Public Member Functions inherited from StringList
static StringList create (const String &list, const char splitter= ',')
 Returns a list that is created by splitting the given (comma-separated) string (String are not trimmed!) More...
 
static StringList create (const char *const *list, UInt size)
 Returns a list that is created from an array of char*. More...
 
- Public Attributes inherited from vector< T >
elements
 STL member. More...
 

Detailed Description

This class handles csv files. Currently only loading is implemented.

Note
items are allowed to be enclosed by only one character e.g. "item" where " is enclosing character

Constructor & Destructor Documentation

CsvFile ( )

Default constructor.

virtual ~CsvFile ( )
virtual

destructor

CsvFile ( const String filename,
char  is = ',',
bool  ie = false,
Int  first_n = -1 
)

Constructor with filename.

Parameters
filenameThe input file name.
ischaracter which separates the items.
ieWhether or not every item is enclosed.
first_nOnly the given number of lines are read, starting from the beginning of the file.
Exceptions
Exception::FileNotFoundis thrown if the file could not be opened.

Member Function Documentation

void fload ( const String filename,
char  is = ',',
bool  ie = false,
Int  first_n = -1 
)

Loads data from a text file.

Parameters
filenameThe input file name.
ischaracter which separates the items.
ieWhether or not every item is enclosed.
first_nOnly the given number of lines are read, starting from the beginning of the file.
Exceptions
Exception::FileNotFoundis thrown if the file could not be opened.
bool getRow ( Size  row,
StringList list 
)

writes all items from a row to list

Parameters
rowthe row which will be read
listStringList which will contain all items of the row
Exceptions
Exception::InvalidIteratoris thrown if the row is not existing
Returns
returns false if the given row could not be separated into items

Member Data Documentation

bool itemenclosed_
private
char itemseperator_
private

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:30 using doxygen 1.8.5