Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/decoda/sae_spec_converter/json_from_da.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,23 @@ def extract_pgns(wb):

pgn_id = int(pgn_id)
if pgn_id != current_pgn["id"]:
# new record found
current_pgn = {
"id": pgn_id,
"name": str(row[name_col]),
"acronym": str(row[acronym_col]),
"description": str(row[description_col]),
"length": int_or_str(row[length_col]),
"rate": str(row[rate_col]),
"source_document": str(row[document_col]),
"spns": [],
}
result.append(current_pgn)

# only create a new record if this PGN hasn't been encountered previously
result_idx = next((i for i, item in enumerate(result) if item.get('id') == pgn_id), -1)
if (result_idx >= 0):
current_pgn = result[result_idx]
else:
current_pgn = {
"id": pgn_id,
"name": str(row[name_col]),
"acronym": str(row[acronym_col]),
"description": str(row[description_col]),
"length": int_or_str(row[length_col]),
"rate": str(row[rate_col]),
"source_document": str(row[document_col]),
"spns": [],
}
result.append(current_pgn)

# Only append SPNs that are valid
spn_id = row[spn_id_col] or ""
if spn_id != "":
Expand Down