mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 21:30:42 +00:00
csv2ifc - add header validation
This commit is contained in:
@@ -86,12 +86,23 @@ class Csv2Ifc:
|
|||||||
if not row[0]:
|
if not row[0]:
|
||||||
continue
|
continue
|
||||||
if row[0] == "HIERARCHY":
|
if row[0] == "HIERARCHY":
|
||||||
|
missing_columns = set(self.SUPPORTED_COLUMNS) - set(row)
|
||||||
|
if missing_columns:
|
||||||
|
raise Exception(
|
||||||
|
f"Header is missing some of the required columns: {', '.join(missing_columns)}."
|
||||||
|
)
|
||||||
|
|
||||||
for i, col in enumerate(row):
|
for i, col in enumerate(row):
|
||||||
if not col:
|
if not col:
|
||||||
continue
|
continue
|
||||||
self.headers[col] = i
|
self.headers[col] = i
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not self.headers:
|
||||||
|
raise Exception(
|
||||||
|
f"No header found in CSV file before data row: '{row}'. Note that header should start with 'HIERARCHY' column."
|
||||||
|
)
|
||||||
|
|
||||||
resource_data = self.get_row_resource_data(row)
|
resource_data = self.get_row_resource_data(row)
|
||||||
hierarchy_key = int(row[0])
|
hierarchy_key = int(row[0])
|
||||||
if hierarchy_key == 1:
|
if hierarchy_key == 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user