csv_object_reader.object_reader module

Utility for parsing csv files.

This module offers more options for restricting and filtering the file contents than python’s built in cvs module.

class csv_object_reader.object_reader.ObjectReader(raw_file, required_items=None, required_groups=None, required_not_empty=True)[source]

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.