mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +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
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.unit
|
import ifcopenshell.util.unit
|
||||||
|
import locale
|
||||||
|
|
||||||
|
|
||||||
class Csv2Ifc:
|
class Csv2Ifc:
|
||||||
@@ -38,7 +39,8 @@ class Csv2Ifc:
|
|||||||
def parse_csv(self):
|
def parse_csv(self):
|
||||||
self.parents = {}
|
self.parents = {}
|
||||||
self.headers = {}
|
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)
|
reader = csv.reader(csv_file)
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if not row[0]:
|
if not row[0]:
|
||||||
@@ -67,7 +69,7 @@ class Csv2Ifc:
|
|||||||
unit = row[self.headers["Unit"]]
|
unit = row[self.headers["Unit"]]
|
||||||
if self.has_categories:
|
if self.has_categories:
|
||||||
cost_values = {
|
cost_values = {
|
||||||
k: float(row[v])
|
k: locale.atof(row[v])
|
||||||
for k, v in self.headers.items()
|
for k, v in self.headers.items()
|
||||||
if k not in ["Hierarchy", "Identification", "Name", "Quantity", "Unit", "Subtotal"] and row[v]
|
if k not in ["Hierarchy", "Identification", "Name", "Quantity", "Unit", "Subtotal"] and row[v]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,9 +233,8 @@ class Ifc5Dwriter:
|
|||||||
"Unit",
|
"Unit",
|
||||||
]
|
]
|
||||||
cost_rate_categories = IfcDataGetter.get_cost_rates_categories(cost_schedule)
|
cost_rate_categories = IfcDataGetter.get_cost_rates_categories(cost_schedule)
|
||||||
self.sheet_data[sheet_id]["headers"].extend(list(cost_rate_categories)).extend(
|
self.sheet_data[sheet_id]["headers"].extend(list(cost_rate_categories))
|
||||||
["Rate Subtotal", "Total Price", "Children"]
|
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]["cost_items"] = IfcDataGetter.get_cost_items_data(self.file, cost_schedule)
|
||||||
self.sheet_data[sheet_id]["UpdateDate"] = IfcDataGetter.canonicalise_time(
|
self.sheet_data[sheet_id]["UpdateDate"] = IfcDataGetter.canonicalise_time(
|
||||||
ifcopenshell.util.date.ifc2datetime(cost_schedule.UpdateDate)
|
ifcopenshell.util.date.ifc2datetime(cost_schedule.UpdateDate)
|
||||||
|
|||||||
Reference in New Issue
Block a user