# tf.contrib.timeseries.CSVReader

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/timeseries/python/timeseries/input_pipeline.py#L436-L513) |

Reads from a collection of CSV-formatted files.

    tf.contrib.timeseries.CSVReader(
        filenames, column_names=(feature_keys.TrainEvalFeatures.TIMES,
        feature_keys.TrainEvalFeatures.VALUES), column_dtypes=None,
        skip_header_lines=None, read_num_records_hint=4096
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `filenames` | A filename or list of filenames to read the time series from. Each line must have columns corresponding to `column_names`. |
| `column_names` | A list indicating names for each feature. `TrainEvalFeatures.TIMES` and `TrainEvalFeatures.VALUES` are required; `VALUES` may be repeated to indicate a multivariate series. |
| `column_dtypes` | If provided, must be a list with the same length as `column_names`, indicating dtypes for each column. Defaults to [`tf.int64`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf#int64) for `TrainEvalFeatures.TIMES` and [`tf.float32`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf#float32) for everything else. |
| `skip_header_lines` | Passed on to [`tf.compat.v1.TextLineReader`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/TextLineReader); skips this number of lines at the beginning of each file. |
| `read_num_records_hint` | When not reading a full dataset, indicates the number of records to parse/transfer in a single chunk (for efficiency). The actual number transferred at one time may be more or less. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If required column names are not specified, or if lengths do not match. |

<br />

## Methods

### `check_dataset_size`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/timeseries/python/timeseries/input_pipeline.py#L169-L183)

    check_dataset_size(
        minimum_dataset_size
    )

When possible, raises an error if the dataset is too small.

This method allows TimeSeriesReaders to raise informative error messages if
the user has selected a window size in their TimeSeriesInputFn which is
larger than the dataset size. However, many TimeSeriesReaders will not have
access to a dataset size, in which case they do not need to override this
method.

<br />

<br />

<br />

| Args ||
|---|---|
| `minimum_dataset_size` | The minimum number of records which should be contained in the dataset. Readers should attempt to raise an error when possible if an epoch of data contains fewer records. |

<br />

### `read`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/timeseries/python/timeseries/input_pipeline.py#L368-L383)

    read()

Reads a chunk of data from the [`tf.compat.v1.ReaderBase`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ReaderBase) for later re-chunking.

### `read_full`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/timeseries/python/timeseries/input_pipeline.py#L385-L433)

    read_full()

Reads a full epoch of data into memory.