Skip to content

Commit

Permalink
Raise error if row is longer than header
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjcantrell committed Dec 19, 2023
1 parent f48b41c commit 6f02448
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions generate_brick.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,12 +682,15 @@ def add_definitions(graph=G):
with open("./bricksrc/definitions.csv", encoding="utf-8") as dictionary_file:
dictionary = csv.reader(dictionary_file)

# skip the header
next(dictionary)
header = next(dictionary)

# add definitions, citations to the graph
for definition in dictionary:
term = URIRef(definition[0])
if len(definition) > len(header):
raise ValueError(
f"The term '{term}' has more elements than expected. Please check the format."
)
if len(definition[1]):
graph.add((term, SKOS.definition, Literal(definition[1], lang="en")))
if len(definition) > 2 and definition[2]:
Expand Down

0 comments on commit 6f02448

Please sign in to comment.