XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
80 stars 136 forks source link

Error "No extension" when indicating a relative path for the input file #573

Closed RafaelKluender closed 2 years ago

RafaelKluender commented 2 years ago

Software and hardware versions

pyxform v1.7.0, Python v3.8

When indicating a relative path for the input file (../folder1/input.xlsx) into the command:

%run -i c:\users...\anaconda3\lib\site-packages\pyxform\xls2xform.py ../folder1/input.xlsx output.xml

I get the error

PyXFormError: No extension.

I am executing xls2xform.py from a python instance.

The full error message:

`--------------------------------------------------------------------------- PyXFormError Traceback (most recent call last) c:\users\kluera\anaconda3\lib\site-packages\pyxform\xls2xform.py in 191 192 if name == "main": --> 193 main_cli()

c:\users\kluera\anaconda3\lib\site-packages\pyxform\xls2xform.py in main_cli() 168 else: 169 try: --> 170 warnings = xls2xform_convert( 171 xlsform_path=args.path_to_XLSForm, 172 xform_path=args.output_path,

c:\users\kluera\anaconda3\lib\site-packages\pyxform\xls2xform.py in xls2xform_convert(xlsform_path, xform_path, validate, pretty_print, enketo) 34 warnings = [] 35 ---> 36 json_survey = xls2json.parse_file_to_json(xlsform_path, warnings=warnings) 37 survey = builder.create_survey_element_from_dict(json_survey) 38 # Setting validate to false will cause the form not to be processed by

~\Anaconda3\envs\python38\lib\site-packages\pyxform\xls2json.py in parse_file_to_json(path, default_name, default_language, warnings, file_object) 1390 if warnings is None: 1391 warnings = [] -> 1392 workbook_dict = parse_file_to_workbook_dict(path, file_object) 1393 fallback_form_name = str(get_filename(path)) 1394 return workbook_to_json(

~\Anaconda3\envs\python38\lib\site-packages\pyxform\xls2json.py in parse_file_to_workbook_dict(path, file_object) 1361 (shortname, extension) = os.path.splitext(filename) 1362 if not extension: -> 1363 raise PyXFormError("No extension.") 1364 1365 if extension in constants.SUPPORTED_FILE_EXTENSIONS:

PyXFormError: No extension.`

lindsay-stevens commented 2 years ago

I can't reproduce this with Windows cmd, Powershell, or Linux bash. Maybe it is something to do with how pyxform is being run. The %run syntax looks like a notebook. Can you try the same outside of a notebook? I don't think running pyxform from a notebook is supported.