Skip to content

nicer error message for missing files #423

@dnkennedy

Description

@dnkennedy

I was using csv2nidm. I had a an errant file name in my command line. I get a very ugly, and not super easy to interpret for the novice user error message

Traceback (most recent call last):
File "/Users/kennedyd/miniforge3/envs/pynidm_2025/bin/csv2nidm", line 8, in
sys.exit(csv2nidm_main())
File "/Users/kennedyd/GitHub/PyNIDM/src/nidm/experiment/tools/csv2nidm.py", line 359, in csv2nidm_main
json_map = csv_dd_to_json_dd(args.csv_map)
File "/Users/kennedyd/GitHub/PyNIDM/src/nidm/experiment/Utils.py", line 3149, in csv_dd_to_json_dd
csv_df = pd.read_csv(csv_file)
File "/Users/kennedyd/miniforge3/envs/pynidm_2025/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1026, in read_csv
return _read(filepath_or_buffer, kwds)
File "/Users/kennedyd/miniforge3/envs/pynidm_2025/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 620, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/Users/kennedyd/miniforge3/envs/pynidm_2025/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1620, in init
self._engine = self._make_engine(f, self.engine)
File "/Users/kennedyd/miniforge3/envs/pynidm_2025/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1880, in _make_engine
self.handles = get_handle(
File "/Users/kennedyd/miniforge3/envs/pynidm_2025/lib/python3.9/site-packages/pandas/io/common.py", line 873, in get_handle
handle = open(
FileNotFoundError: [Errno 2] No such file or directory: 'CSVs/mriqc/mriqc_dictionary_v1.csv'

Which seems way to lengthy and uninformative to just say, "Hey, one of the file names you gave me doesn't exist.

It seems to me that at the beginning of the csv2nidm program, we sould just check for the existance of all files provided, and if any are missing, a clearer and simpler error message could be provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions