Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1226 | CSV -> JSON | custom attributes data…
Browse files Browse the repository at this point in the history
…type json
  • Loading branch information
snyaggarwal committed Mar 15, 2022
1 parent 03a74a9 commit 5f5cb95
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ocldev/oclcsvtojsonconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def get_auto_extra_attributes(self, csv_row, auto_attributes_def):
re.escape(auto_attributes_def[self.DEF_KEY_AUTO_INDEX_PREFIX]),
auto_attributes_def[self.DEF_KEY_AUTO_INDEX_REGEX],
re.escape(auto_attributes_def[self.DEF_KEY_AUTO_INDEX_POSTFIX]))
data_types = ['bool', 'str', 'int', 'float', 'list']

data_types = ['bool', 'str', 'int', 'float', 'list', 'json']

# Process CSV columns
for column_name in csv_row:
Expand Down Expand Up @@ -727,6 +728,11 @@ def do_datatype_conversion(self, value, datatype):
return float(value)
elif datatype == 'list':
return [v.strip() for v in value.strip('][').split(',')]
elif datatype == 'json':
try:
return json.loads(value)
except:
return value
return value

def process_auto_concept_reference(self, csv_row, field_def):
Expand Down

0 comments on commit 5f5cb95

Please sign in to comment.