csv_object_reader package¶
Module contents¶
- class csv_object_reader.ObjectReader(raw_file, required_items=None, required_groups=None, required_not_empty=True)¶
Bases: object
Returns an objects for each record in a csv file
Parameters: - raw_file – Can be any object which supports the iterator protocol and returns a string each time its next() method is called.
- required_items – List of field names which must appear in the header.
- required_groups – List of groups. Each group is a list of field names. For each group, at least one of the specified fields must appear in the header.
- required_not_empty – If true, required fields and groups must also be not empty.
Raises: - ValueError – If the header is empty or malformed.
- AttributeError – If required fields or groups are not present.
- class csv_object_reader.Filter(field, value=None, invert=False, missing_is_pass=False)¶
Bases: object
Basic Filter, uses == to compare values.
Parameters: - field – name of field to filter on
- value – required value of the specified field, if None checks that the field exists
- invert – invert the results of the filter. Ignored if value is None.
- missing_is_pass – if True and field is not present, pass this entry instead of failing it (the default). Ignored if value is None.
- test(entry)¶
Test the provided entry against this filer.
Parameters: entry – entry to test against the filter. Returns: True if the entry passes the filter, otherwise False.
- class csv_object_reader.RegexFilter(field, value=None, invert=False, missing_is_pass=False)¶
Bases: csv_object_reader.filter.Filter
Filter which uses regex match to compare values.