NOTICE: All information contained herein is, and remains
the property of TechnoCore Automate.
The ObjImportApi class in ObjDataImportAvro.py imports data from Apache
Avro (.avro) files using the fastavro library. It follows the same
open_file / column_list / next_row / close_file interface used by all
other ObjDataImport* modules.
Each Avro record is natively a dict, so no conversion is needed. The entire
file is read into memory on open_file.
prep_file(filename) -> strNo-op — returns the filename unchanged.
open_file(filename)Opens the Avro file in binary mode and reads all records using
fastavro.reader. Column names are taken from the keys of the first record.
close_file()Releases the in-memory record list.
column_list() -> listReturns the column names derived from the first record's keys.
next_row() -> list | strReturns the next record as a list of values in column order. Keys missing from
a record are returned as "". Returns "EOF" when all records have been read.
importer = ObjImportApi()
importer.open_file("data.avro")
columns = importer.column_list()
print("Columns:", columns)
while True:
row = importer.next_row()
if row == "EOF":
break
print(dict(zip(columns, row)))
importer.close_file()
Requires the fastavro package:
pip install fastavro
Updated: 2026-03-22