diff --git a/neo/io/__init__.py b/neo/io/__init__.py index 69a88ebe8..4aa316921 100644 --- a/neo/io/__init__.py +++ b/neo/io/__init__.py @@ -452,12 +452,22 @@ def list_candidate_ios(file_or_folder, ignore_patterns=['*.ini', 'README.txt', ' # to select all files sharing the `session1-` prefix elif file_or_folder.parent.exists(): filenames = list(file_or_folder.parent.glob(file_or_folder.name + '*')) + # if filenames empty and suffix is provided then non-existent file + # may be written in current dir. So run check for io if len(filenames)==0 and file_or_folder.suffix: suffix = file_or_folder.suffix[1:].lower() if suffix not in io_by_extension: raise ValueError(f'{suffix} is not a supported format of any IO.') return io_by_extension[suffix] + # If non-existent file in non-existent dir is given check if this + # structure could be created with an io writing the file + elif file_or_folder.suffix: + suffix = file_or_folder.suffix[1:].lower() + if suffix not in io_by_extension: + raise ValueError(f'{suffix} is not a supported format of any IO.') + return io_by_extension[suffix] + else: raise ValueError(f'{file_or_folder} does not contain data files of a supported format')