Raise error on invalid path. Fixes #5
This commit is contained in:
parent
538120ce82
commit
aa4e0cd60c
|
|
@ -34,6 +34,9 @@ def read_ods(
|
||||||
Returns:
|
Returns:
|
||||||
The content of the specified sheet as a DataFrame.
|
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)
|
backend = EXT_MAP.get(Path(file_or_path).suffix, ods)
|
||||||
return algo.read_data(
|
return algo.read_data(
|
||||||
backend,
|
backend,
|
||||||
|
|
|
||||||
|
|
@ -156,3 +156,9 @@ class TestOdsReader:
|
||||||
assert len(df) == 8
|
assert len(df) == 8
|
||||||
assert len(df.columns) == 5
|
assert len(df.columns) == 5
|
||||||
assert df.columns.tolist() == ["a", "b", "c", "d", "e"]
|
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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue