Fixed-width reader - agate 1.9.0 documentation

Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Fixed-width reader

Agate contains a fixed-width file reader that is designed to work like Python’s `csv`.

These readers work with CSV-formatted schemas, such as those maintained at wireservice/ffs.

`agate.fixed.reader` | A wrapper around `fixed.Reader`, so that it can be used in the same way as a normal CSV reader.
`agate.fixed.Reader` | Reads a fixed-width file using a column schema in CSV format.
`agate.fixed.DictReader` | A fixed-width reader that returns `collections.OrderedDict` rather than a list.

## Detailed list

agate.fixed.reader(*args, **kwargs)

  A wrapper around `fixed.Reader`, so that it can be used in the same way as a normal CSV reader.

class agate.fixed.Reader(f, schema_f)

  Bases: `object`

  Reads a fixed-width file using a column schema in CSV format.

  This works almost exactly like Python’s built-in CSV reader.

  Schemas must be in the “ffs” format, with `column`, `start`, and `length` columns. There is a repository of such schemas maintained at wireservice/ffs.

  property fieldnames

    The names of the columns read from the schema.

class agate.fixed.DictReader(f, schema_f)

  Bases: `Reader`

  A fixed-width reader that returns `collections.OrderedDict` rather than a list.