record

This module defines a Record and ways to generate iterators of records.


class polymr.record.Record

This class defines a record, the basic unit of information contained in the index.

Parameters:
  • fields (tuple of str) – The attributes used to find a record. Searchers will supply something like these to find records and the indexer will use these to organize the records for easy lookup
  • pk (tuple of str) – The primary key used to find this record in other databases.
  • data – The attributes not used to find a record, but you want to store anyway.
polymr.record.from_csv(f, searched_fields_idxs=None, pk_field_idx=None, include_data=True, delimiter=', ')

Parse a csv file into an iterator of polymr.record.Record

Parameters:
  • f (Open file handle) – The csv file
  • searched_fields_idxs (int) – The 0-based column numbers to use for record search fields
  • searched_fields_idxs – The 0-based column number to use for the primary key attribute
  • include_data (bool) – True to yield records with data attributes filled in, False to yield records with data attributes set to empty tuples
  • delimiter (str) – The field delimiter in the csv file c.f. Python’s csv module.
Returns:

Iterator of polymr.record.Record

polymr.record.from_psv(f, searched_fields_idxs=None, pk_field_idx=None, include_data=True)

Parse a psv file into an iterator of polymr.record.Record. Psv is often what you get from Postgres psql output.

Parameters:
  • f (Open file handle) – The psv file
  • searched_fields_idxs (int) – The 0-based column numbers to use for record search fields
  • searched_fields_idxs – The 0-based column number to use for the primary key attribute
  • include_data (bool) – True to yield records with data attributes filled in, False to yield records with data attributes set to empty tuples
Returns:

Iterator of polymr.record.Record