Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Generalizing class location for table converter #967

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions gldcore/converters/csv-table2glm-object.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,25 @@ def convert (p_configuration_in, p_configuration_out, options={} ) :
if i == 0 :
headers = row
else :
if not row[0] and not options :
if "class" not in headers and not options:
error("No class name found, please edit your CSV to include class or add -C <class name> to your input command")
if not row[0] :
else :
class_index=headers.index("class")

if not row[class_index] :
p_config_out.write(f"object {options['class']} ")
class_name = options['class']
if row[0] :
p_config_out.write(f"object {row[0]} ")
class_name = row[0]
if row[class_index] :
p_config_out.write(f"object {row[class_index]} ")
class_name = row[class_index]
p_config_out.write("{ \n")
for j,value in enumerate (row) :
if j>0 :
if j!=class_index and headers[j] :
if not value and headers[j].strip()=="name" :
p_config_out.write("\t" + headers[j].strip() + " " + class_name +"_" + str(i) + ";\n")
else :
if value :
if re.findall('^\d+',value) or value.startswith('(') or ' ' in value:
if re.findall('^\d+',value) or value.startswith('(') or '([0-9]*\ [*a-zA-Z+]*){0,1}?' in value and ',' not in value:
p_config_out.write("\t" + headers[j].strip() + " " + value + ";\n")
else :
p_config_out.write("\t" + headers[j].strip() + " " + "\"" +value + "\"" + ";\n")
Expand Down