<!-- This file is machine generated: DO NOT EDIT! -->

# Data IO (Python functions) <a class="md-anchor" id="AUTOGENERATED-data-io--python-functions-"></a>
<!-- TOC-BEGIN This section is generated by neural network: DO NOT EDIT! -->
## Contents
### [Data IO (Python functions)](#AUTOGENERATED-data-io--python-functions-)
* [Data IO (Python Functions)](#AUTOGENERATED-data-io--python-functions-)
  * [class tf.python_io.TFRecordWriter](#TFRecordWriter)
  * [`tf.python_io.tf_record_iterator(path)`](#tf_record_iterator)
  * [TFRecords Format Details](#AUTOGENERATED-tfrecords-format-details)


<!-- TOC-END This section was generated by neural network, THANKS FOR READING! -->

## Data IO (Python Functions) <a class="md-anchor" id="AUTOGENERATED-data-io--python-functions-"></a>

A TFRecords file represents a sequence of (binary) strings.  The format is not
random access, so it is suitable for streaming large amounts of data but not
suitable if fast sharding or other non-sequential access is desired.

- - -

### class tf.python_io.TFRecordWriter <a class="md-anchor" id="TFRecordWriter"></a>

A class to write records to a TFRecords file.

This class implements `__enter__` and `__exit__`, and can be used
in `with` blocks like a normal file.

- - -

#### `tf.python_io.TFRecordWriter.__init__(path)` <a class="md-anchor" id="TFRecordWriter.__init__"></a>

Opens file `path` and creates a `TFRecordWriter` writing to it.

##### Args: <a class="md-anchor" id="AUTOGENERATED-args-"></a>


*  <b>path</b>: The path to the TFRecords file.

##### Raises: <a class="md-anchor" id="AUTOGENERATED-raises-"></a>


*  <b>IOError</b>: If `path` cannot be opened for writing.


- - -

#### `tf.python_io.TFRecordWriter.write(record)` <a class="md-anchor" id="TFRecordWriter.write"></a>

Write a string record to the file.

##### Args: <a class="md-anchor" id="AUTOGENERATED-args-"></a>


*  <b>record</b>: str


- - -

#### `tf.python_io.TFRecordWriter.close()` <a class="md-anchor" id="TFRecordWriter.close"></a>

Close the file.



- - -

### `tf.python_io.tf_record_iterator(path)` <a class="md-anchor" id="tf_record_iterator"></a>

An iterator that read the records from a TFRecords file.

##### Args: <a class="md-anchor" id="AUTOGENERATED-args-"></a>


*  <b>path</b>: The path to the TFRecords file.

##### Yields: <a class="md-anchor" id="AUTOGENERATED-yields-"></a>

  Strings.

##### Raises: <a class="md-anchor" id="AUTOGENERATED-raises-"></a>


*  <b>IOError</b>: If `path` cannot be opened for reading.



- - -

### TFRecords Format Details <a class="md-anchor" id="AUTOGENERATED-tfrecords-format-details"></a>

A TFRecords file contains a sequence of strings with CRC hashes.  Each record
has the format

    uint64 length
    uint32 masked_crc32_of_length
    byte   data[length]
    uint32 masked_crc32_of_data

and the records are concatenated together to produce the file.  The CRC32s
are [described here](https://en.wikipedia.org/wiki/Cyclic_redundancy_check),
and the mask of a CRC is

    masked_crc = ((crc >> 15) | (crc << 17)) + 0xa282ead8ul
