CSV reader and writer — agate 1.6.3 documentation

# CSV reader and writer

Agate contains CSV readers and writers that are intended to be used as a drop-in replacement for `csv`. These versions add unicode support for Python 2 and several other minor features.

Agate methods will use these version automatically. If you would like to use them in your own code, you can import them, like this:

    from agate import csv

Due to nuanced differences between the versions, these classes are implemented seperately for Python 2 and Python 3. The documentation for both versions is provided below, but only the one for your version of Python is imported with the above code.

## Python 3

`agate.csv_py3.reader` | A replacement for Python's `csv.reader()` that uses `csv_py3.Reader`.
`agate.csv_py3.writer` | A replacement for Python's `csv.writer()` that uses `csv_py3.Writer`.
`agate.csv_py3.Reader` | A wrapper around Python 3's builtin `csv.reader()`.
`agate.csv_py3.Writer` | A wrapper around Python 3's builtin `csv.writer()`.
`agate.csv_py3.DictReader` | A wrapper around Python 3's builtin `csv.DictReader`.
`agate.csv_py3.DictWriter` | A wrapper around Python 3's builtin `csv.DictWriter`.

## Python 2

`agate.csv_py2.reader` | A replacement for Python's `csv.reader()` that uses `csv_py2.Reader`.
`agate.csv_py2.writer` | A replacement for Python's `csv.writer()` that uses `csv_py2.Writer`.
`agate.csv_py2.Reader` | A unicode-aware CSV reader.
`agate.csv_py2.Writer` | A unicode-aware CSV writer.
`agate.csv_py2.DictReader` | A unicode-aware CSV DictReader.
`agate.csv_py2.DictWriter` | A unicode-aware CSV DictWriter.

## Python 3 details

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

  A replacement for Python’s `csv.reader()` that uses `csv_py3.Reader`.

agate.csv_py3.writer(*args, **kwargs)

  A replacement for Python’s `csv.writer()` that uses `csv_py3.Writer`.

class agate.csv_py3.Reader(f, field_size_limit=None, line_numbers=False, header=True, **kwargs)

  A wrapper around Python 3’s builtin `csv.reader()`.

class agate.csv_py3.Writer(f, line_numbers=False, **kwargs)

  A wrapper around Python 3’s builtin `csv.writer()`.

class agate.csv_py3.DictReader(f, fieldnames=None, restkey=None, restval=None, dialect='excel', *args, **kwds)

  A wrapper around Python 3’s builtin `csv.DictReader`.

class agate.csv_py3.DictWriter(f, fieldnames, line_numbers=False, **kwargs)

  A wrapper around Python 3’s builtin `csv.DictWriter`.

## Python 2 details

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

  A replacement for Python’s `csv.reader()` that uses `csv_py2.Reader`.

agate.csv_py2.writer(*args, **kwargs)

  A replacement for Python’s `csv.writer()` that uses `csv_py2.Writer`.

class agate.csv_py2.Reader(f, encoding='utf-8', field_size_limit=None, line_numbers=False, header=True, **kwargs)

  A unicode-aware CSV reader.

class agate.csv_py2.Writer(f, encoding='utf-8', line_numbers=False, **kwargs)

  A unicode-aware CSV writer.

class agate.csv_py2.DictReader(f, fieldnames=None, restkey=None, restval=None, *args, **kwargs)

  A unicode-aware CSV DictReader.

class agate.csv_py2.DictWriter(f, fieldnames, encoding='utf-8', line_numbers=False, **kwargs)

  A unicode-aware CSV DictWriter.