diff --git a/src/ifc5d/ifc5d/csv2ifc.py b/src/ifc5d/ifc5d/csv2ifc.py index 2e362d302e..7632b10f44 100644 --- a/src/ifc5d/ifc5d/csv2ifc.py +++ b/src/ifc5d/ifc5d/csv2ifc.py @@ -20,6 +20,7 @@ import csv import ifcopenshell import ifcopenshell.api import ifcopenshell.util.unit +import locale class Csv2Ifc: @@ -38,7 +39,8 @@ class Csv2Ifc: def parse_csv(self): self.parents = {} self.headers = {} - with open(self.csv, "r") as csv_file: + locale.setlocale(locale.LC_ALL, "") # set the system locale + with open(self.csv, "r", encoding="ISO-8859-1") as csv_file: reader = csv.reader(csv_file) for row in reader: if not row[0]: @@ -67,7 +69,7 @@ class Csv2Ifc: unit = row[self.headers["Unit"]] if self.has_categories: cost_values = { - k: float(row[v]) + k: locale.atof(row[v]) for k, v in self.headers.items() if k not in ["Hierarchy", "Identification", "Name", "Quantity", "Unit", "Subtotal"] and row[v] } diff --git a/src/ifc5d/ifc5d/ifc5Dspreadsheet.py b/src/ifc5d/ifc5d/ifc5Dspreadsheet.py index 7c91934790..546f2bd2c1 100644 --- a/src/ifc5d/ifc5d/ifc5Dspreadsheet.py +++ b/src/ifc5d/ifc5d/ifc5Dspreadsheet.py @@ -233,9 +233,8 @@ class Ifc5Dwriter: "Unit", ] cost_rate_categories = IfcDataGetter.get_cost_rates_categories(cost_schedule) - self.sheet_data[sheet_id]["headers"].extend(list(cost_rate_categories)).extend( - ["Rate Subtotal", "Total Price", "Children"] - ) + self.sheet_data[sheet_id]["headers"].extend(list(cost_rate_categories)) + self.sheet_data[sheet_id]["headers"].extend(["Rate Subtotal", "Total Price", "Children"]) self.sheet_data[sheet_id]["cost_items"] = IfcDataGetter.get_cost_items_data(self.file, cost_schedule) self.sheet_data[sheet_id]["UpdateDate"] = IfcDataGetter.canonicalise_time( ifcopenshell.util.date.ifc2datetime(cost_schedule.UpdateDate)