Skip to content

Commit

Permalink
solving issue #79
Browse files Browse the repository at this point in the history
  • Loading branch information
dachafra committed Feb 27, 2024
1 parent 5a9be58 commit ca4f510
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/yatter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@
'json': 'JSONPath',
'xpath': 'XPath',
'jsonpath': 'JSONPath',
"shp": "SHP"
"shp": "SHP",
"xlsx": "CSV"
}

YARRRML_DATABASES_DRIVER = {
Expand Down
11 changes: 8 additions & 3 deletions src/yatter/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ def add_source_simplified(mapping, source):
source_extension = os.path.splitext(file_path)[1].replace(".","")
ref_formulation_rml = YARRRML_REFERENCE_FORMULATIONS[reference_formulation]

if switch_in_reference_formulation(reference_formulation) != source_extension:
if switch_in_reference_formulation(reference_formulation, source_extension) != source_extension:
raise Exception(
"ERROR: mismatch extension and referenceFormulation in source " + source + " in mapping " + mapping)
else:
if len(source) == 1: # do not have iterator
if source_extension == "csv" or source_extension == "SQL2008":
if source_extension == "csv" or source_extension == "SQL2008" or source_extension == "xlsx":
source_rdf += '"' + file_path + '"' + ";\n" + "\t\t" + RML_REFERENCE_FORMULATION + " ql:" \
+ ref_formulation_rml + "\n" + "\t];\n"
else:
Expand Down Expand Up @@ -169,7 +169,7 @@ def database_source(mapping, source, db_identifier):
return source_rdf


def switch_in_reference_formulation(value):
def switch_in_reference_formulation(value, source_extension=None):
value = value.lower()
if "json" in value:
if "path" in value:
Expand All @@ -181,6 +181,11 @@ def switch_in_reference_formulation(value):
switcher = "xml"
else:
switcher = "xpath"
elif source_extension:
if source_extension == "xlsx":
switcher = "xlsx"
else:
switcher = value
else:
switcher = value
return switcher
Expand Down

0 comments on commit ca4f510

Please sign in to comment.