Table Of Contents
Table Of Contents

MXRecordIO

class mxnet.recordio.MXRecordIO(uri, flag)[source]

Reads/writes RecordIO data format, supporting sequential read and write.

>>> record = mx.recordio.MXRecordIO('tmp.rec', 'w')
<mxnet.recordio.MXRecordIO object at 0x10ef40ed0>
>>> for i in range(5):
...    record.write('record_%d'%i)
>>> record.close()
>>> record = mx.recordio.MXRecordIO('tmp.rec', 'r')
>>> for i in range(5):
...    item = record.read()
...    print(item)
record_0
record_1
record_2
record_3
record_4
>>> record.close()
Parameters:
  • uri (string) – Path to the record file.
  • flag (string) – ‘w’ for write or ‘r’ for read.
__init__(uri, flag)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(uri, flag) Initialize self.
close() Closes the record file.
open() Opens the record file.
read() Returns record as a string.
reset() Resets the pointer to first item.
write(buf) Inserts a string buffer as a record.