fix 5d csv imports with funky characters and numbers, fix 5d export

This commit is contained in:
Sigma Dimensions
2023-03-01 10:51:52 +01:00
parent 12151c40ff
commit d40dcae212
2 changed files with 6 additions and 5 deletions
+4 -2
View File
@@ -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]
}
+2 -3
View File
@@ -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)