diff --git a/pandas_ods_reader/main.py b/pandas_ods_reader/main.py index a043ab8..8d0e650 100644 --- a/pandas_ods_reader/main.py +++ b/pandas_ods_reader/main.py @@ -34,6 +34,9 @@ def read_ods( Returns: The content of the specified sheet as a DataFrame. """ + path = file_or_path if isinstance(file_or_path, Path) else Path(file_or_path) + if not path.is_file(): + raise FileNotFoundError(f"file {file_or_path} does not exist") backend = EXT_MAP.get(Path(file_or_path).suffix, ods) return algo.read_data( backend, diff --git a/tests/test_read_ods.py b/tests/test_read_ods.py index aa3aa9c..730bd29 100644 --- a/tests/test_read_ods.py +++ b/tests/test_read_ods.py @@ -156,3 +156,9 @@ class TestOdsReader: assert len(df) == 8 assert len(df.columns) == 5 assert df.columns.tolist() == ["a", "b", "c", "d", "e"] + + def test_invalid_path(self): + + path = rsc / "does-not-exist.ods" + with pytest.raises(FileNotFoundError, match="does not exist"): + read_ods(path)