TableReader¶
-
class
ctapipe.io.
TableReader
(**kwargs: Any)[source]¶ Bases:
ctapipe.core.component.Component
Base class for row-wise table readers. Generally methods that read a full table at once are preferred to this method, since they are faster, but this can be used to re-play a table row by row into a
ctapipe.core.Container
class (the opposite of TableWriter)Methods Summary
add_column_transform
(table_name, col_name, …)Add a transformation function for a column.
close
()open
(filename, **kwargs)read
(table_name, containers, prefixes, **kwargs)Returns a generator that reads the next row from the table into the given container.
Methods Documentation
-
add_column_transform
(table_name, col_name, transform)[source]¶ Add a transformation function for a column. This function will be called on the value in the container before it is written to the output file.
- Parameters
- table_name: str
identifier of table being written
- col_name: str
name of column in the table (or item in the Container)
- transform: callable
function that take a value and returns a new one
-
abstract
read
(table_name, containers, prefixes, **kwargs)[source]¶ Returns a generator that reads the next row from the table into the given container. The generator returns the same container. Note that no containers are copied, the data are overwritten inside.
- Parameters
- table_name: str
name of table to read from
- containers: ctapipe.core.Container or iterable thereof
Container instance(s) to fill
- prefixes: bool, str or iterable of str
prefixes used during writing of the table
-