NOTICE: All information contained herein is, and remains
the property of TechnoCore Automate.
The ObjImportApi class in ObjDataImportYaml.py imports data from YAML files
that contain either a top-level list of dicts or a dict with a nested list of
dicts. It follows the same open_file / column_list / next_row /
close_file interface used by all other ObjDataImport* modules.
Uses yaml.safe_load() exclusively (never FullLoader) for security. The entire
file is loaded into memory on open_file.
prep_file(filename) -> strNo-op — returns the filename unchanged.
open_file(filename)Loads the YAML file and parses it. Handles two structures:
The column list is 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.yaml")
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()
List of dicts (direct):
- id: 1
name: Alice
score: 95
- id: 2
name: Bob
score: 82
Dict with nested list:
metadata:
source: export
records:
- id: 1
name: Alice
score: 95
- id: 2
name: Bob
score: 82
Updated: 2026-03-22