ASCII spreadsheet API¶
pni::spreadsheet_reader
¶
-
class spreadsheet_reader : public pni::data_reader¶
base class for spreadsheet reader
This class is the basement for all readers dealing with spreadsheet like data files. Most of the ASCII formats written following this storage convention.
Subclassed by pni::fio_reader
Public Types
-
typedef std::vector<column_info>::iterator iterator¶
iterator type
-
typedef std::vector<column_info>::const_iterator const_iterator¶
const iterator type
Public Functions
-
virtual ~spreadsheet_reader()¶
destructor
-
spreadsheet_reader &operator=(const spreadsheet_reader&) = delete¶
copy assignment operator is deleted
-
spreadsheet_reader &operator=(spreadsheet_reader &&r)¶
move assignment operator
-
inline size_t ncolumns() const¶
get column number
Returns the number of columns.
- Returns:
number of columns
-
inline size_t nrecords() const¶
get record number
Return the number of records in the spreadsheet.
- Returns:
number of records
-
inline iterator begin()¶
get iterator to first column
Return an iterator pointing to the first column in the file.
- Returns:
iterator
-
inline const_iterator begin() const¶
get const first iterator
Return a const iterator to the first column in the file.
- Returns:
const iterator
-
inline iterator end()¶
get last iterator
Return an iterator to the last column in the file.
- Returns:
iterator
-
inline const_iterator end() const¶
get const last iterator
Returns a const iterator to the last column in the file.
- Returns:
const iterator
-
bool has_column(const pni::string &name) const¶
checks if a particular column exists
Returns true if the spreadsheet contains a column of the requested name and false otherwise.
- Parameters:
name – of the column
- Returns:
true if column exists, false otherwise
-
typedef std::vector<column_info>::iterator iterator¶
pni::column_info
¶
-
class column_info¶
Spreadsheet column information.
This class holds the basic information about a column stored in a spreadsheet. This includes the following parameters: the name of the column, its TypeID and the shape of each cell. The latter parameter allows even the storage of multidimensional data in such a structure.
Public Functions
-
column_info()¶
default constructor
-
column_info(const column_info &ci)¶
copy constructor
-
column_info(column_info &&ci)¶
move constructor
-
column_info(const pni::string &n, pni::type_id_t tid, const std::vector<size_t> &s)¶
constructor
A column can hold a scalar or a multidimensional data entry. In the former case the type id is that of the element stored in the latter case it is the id of a single element in the array stored in each column element.
- Parameters:
n – name of the column
tid – ID of the type stored in the column
s – shape of the column
-
~column_info()¶
destructor
-
column_info &operator=(const column_info &ci)¶
copy assignment operator
-
column_info &operator=(column_info &&ci)¶
move assignment operator
-
inline const std::vector<size_t> &shape() const¶
get cell shape
Returns the shape object from a column.
- Returns:
shape object.
-
inline pni::type_id_t type_id() const¶
get cells type ID
Return the TypeID of the column if available. This is only valid for systems where type information is stored in the file (like for FIO).
- Returns:
type id of the column data
-
inline pni::string name() const¶
get name
Return the name of the column.
- Returns:
name
-
column_info()¶
pni::fio_reader
¶
-
class fio_reader : public pni::spreadsheet_reader¶
FIO data reader.
FIO files are written by ONLINE a data acquisition and experiment control software used at DESY. FIO files are basically ACII files where data is stored in columns. Thus such files correspond to the family of spreadsheet style files.
Public Functions
-
fio_reader()¶
default constructor
-
fio_reader(const fio_reader &r) = delete¶
copy construction is deleted
-
fio_reader(fio_reader &&r) = default¶
move constructor
-
fio_reader(const pni::string &n)¶
standard constructor
-
~fio_reader()¶
destructor
-
fio_reader &operator=(const fio_reader &r) = delete¶
copy assignment is deleted
-
fio_reader &operator=(fio_reader &&r) = default¶
move assignemnt operator
-
size_t nparameters() const¶
get number of parameters
Return the number of parameters stored in the file.
- Returns:
number of parameters
-
std::vector<std::string> parameter_names() const¶
get parameter names
Returns a vector of Strings holding the parameter names stored in the file.
- Returns:
parameter names
-
template<typename ElementT>
ElementT parameter(const std::string &name) const¶ get parameter by name
Return the value of a parameter stored in the FIO file by name.
- Throws:
key_errror – if parameter name does not exist
- Parameters:
name – parameter name
- Returns:
parameter value as type ElementT
-
template<typename ContainerT>
ContainerT column(const std::string &n) const¶ get single column
Returns a single column and stores the data into an array object. If the column name does not exist an exception is thrown.
- Throws:
key_error – if column does not exist
file_error – if EOF is reached before end of data
- Parameters:
n – name of the column
- Returns:
instance of ArrayT holding the data.
-
template<typename ContainerT>
void column(const std::string &n, ContainerT &c) const¶ read single column
Read a single column and stores the result in an appropriate container. The method assumes that the container is of appropriate size and shape.
- Throws:
key_error – if the requested column does not exist
file_error – in any other case of error
- Template Parameters:
ContainerT – container type
- Parameters:
n – name of the column
c – instance of ContainerT that will in the end contain the data
-
fio_reader()¶