{"id":28386,"library":"tfrecord-lite","title":"tfrecord-lite","description":"A lightweight tfrecord parser that reads TensorFlow TFRecord files without requiring TensorFlow. Version 0.0.8 supports Python >=3.6 and provides both low-level reading and higher-level dataset creation.","status":"active","version":"0.0.8","language":"python","source_language":"en","source_url":"https://github.com/jongwook/tfrecord_lite","tags":["tfrecord","tensorflow","machine-learning","data-formats"],"install":[{"cmd":"pip install tfrecord-lite","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for decoding TensorFlow protos (e.g., Int64List, FloatList)","package":"numpy","optional":false},{"reason":"Optional, only if you want to use tfrecord_lite.data.TFRecordDataset (uses tf.data)","package":"tensorflow","optional":true}],"imports":[{"note":"","wrong":"","symbol":"TFRecordLoader","correct":"from tfrecord_lite import decode_example"},{"note":"Common mistake: package is tfrecord-lite, not tfrecord","wrong":"from tfrecord import TFRecordWriter","symbol":"TFRecordWriter","correct":"from tfrecord_lite import TFRecordWriter"},{"note":"The iterator is a top-level function, not a submodule","wrong":"from tfrecord_lite.iterator import tf_record_iterator","symbol":"TFRecordIterator","correct":"from tfrecord_lite import tf_record_iterator"}],"quickstart":{"code":"import tfrecord_lite\n\n# Write a TFRecord file\nwriter = tfrecord_lite.TFRecordWriter('example.tfrecord')\nwriter.write(b'Hello, world!')\nwriter.close()\n\n# Read back with iterator\nfor record in tfrecord_lite.tf_record_iterator('example.tfrecord'):\n    print(record)  # b'Hello, world!'\n\n# Decode TFRecord with TensorFlow proto (requires numpy)\nfrom tfrecord_lite import decode_example\n# Assuming you have an Example proto bytes\n# example_bytes = ...\n# result = decode_example(example_bytes)  # returns dict of numpy arrays\n","lang":"python","description":"Basic read/write operations using tfrecord-lite."},"warnings":[{"fix":"Encode strings to bytes: writer.write('text'.encode())","message":"TFRecordWriter.write expects bytes, not str. If you pass a string, it will fail with TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Use decode_example from tfrecord_lite to parse Example protos.","message":"tf_record_iterator yields raw bytes records. It does NOT decode TensorFlow Example protos automatically.","severity":"gotcha","affected_versions":"all"},{"fix":"Use decode_example instead of TFRecordLoader.","message":"There is no deprecated API in current version. However, note that TFRecordLoader is no longer present in recent versions; it was renamed to decode_example.","severity":"deprecated","affected_versions":">=0.0.7"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install TensorFlow: pip install tensorflow, or avoid using TFRecordDataset and use tf_record_iterator instead.","cause":"You are trying to import tfrecord_lite.data.TFRecordDataset which requires TensorFlow.","error":"ModuleNotFoundError: No module named 'tensorflow'"},{"fix":"Encode string: writer.write('data'.encode())","cause":"You passed a string to TFRecordWriter.write() instead of bytes.","error":"TypeError: a bytes-like object is required, not 'str'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}