DataReader
The DataReader
is a base class for which may be used to generate data that
is processed by PZ.
Subclasses of the (abstract) DataReader
class must implement two methods:
__len__()
: which returns the number of elements in the data source__getitem__(idx: int)
: which takes in anidx
and returns the element at that index
__init__
Constructor for the DataReader
class.
Parameters:
-
schema
(Schema | list[dict]
) –The output schema of the records returned by the DataReader
__getitem__
abstractmethod
Returns a single item from the data reader at the given index.
Parameters:
-
idx
(int
) –The index of the item to return
Returns:
-
dict
(dict
) –A dictionary representing the item at the given index. The dictionary keys (i.e. fields) should match the fields specified in the schema of the data source, and the values should be the values associated with those fields.
# Example return value {"field1": value1, "field2": value2, ...}