From f56269301fa950308f3c61051504c7d98f88f6e6 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 28 Jul 2020 11:47:22 +1000 Subject: [PATCH] Fix bug where IFCCSV won't correctly store boolean data types --- src/ifccsv/ifccsv.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ifccsv/ifccsv.py b/src/ifccsv/ifccsv.py index e099621be2..6d28a4f218 100644 --- a/src/ifccsv/ifccsv.py +++ b/src/ifccsv/ifccsv.py @@ -248,7 +248,18 @@ class IfcAttributeExtractor(): def set_pset_property(pset, name, value): for property in pset.HasProperties: if property.Name == name: - property.NominalValue.wrappedValue = value + # In lieu of loading a map for data casting, we only have four + # options, which this ugly method will determine. + try: + property.NominalValue.wrappedValue = str(value) + except: + try: + property.NominalValue.wrappedValue = float(value) + except: + try: + property.NominalValue.wrappedValue = int(value) + except: + property.NominalValue.wrappedValue = True if value.lower() in ['1', 't', 'true', 'yes', 'y', 'uh-huh'] else False class IfcCsv():