mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
fix 5d csv imports with funky characters and numbers, fix 5d export
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user