Skip to content

Commit

Permalink
Renamed dataclasses.py to data_objects.py; Moved conversion of string…
Browse files Browse the repository at this point in the history
… to Path object to geost.read.__read_file()
  • Loading branch information
Erik-Geo committed Oct 2, 2024
1 parent cfcc69a commit b7aa71a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
File renamed without changes.
15 changes: 7 additions & 8 deletions geost/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}


def __read_file(file: WindowsPath, **kwargs) -> pd.DataFrame:
def __read_file(file: str | WindowsPath, **kwargs) -> pd.DataFrame:
"""
Read parquet file.
Expand All @@ -71,6 +71,7 @@ def __read_file(file: WindowsPath, **kwargs) -> pd.DataFrame:
if 'file' has no valid suffix.
"""
file = Path(file)
suffix = file.suffix
if suffix in [".parquet", ".pq"]:
return pd.read_parquet(file, **kwargs)
Expand Down Expand Up @@ -221,7 +222,7 @@ def read_borehole_table(
>>> read_borehole_table(file, 32631, 'Ostend height', column_mapper={'maaiveld': 'surface'})
"""
boreholes = __read_file(Path(file), **kwargs)
boreholes = __read_file(file, **kwargs)

if has_inclined:
boreholes = _check_mandatory_column_presence(
Expand Down Expand Up @@ -294,8 +295,7 @@ def read_cpt_table(
Instance of :class:`~geost.base.CptCollection`.
"""
filepath = Path(file)
cpts = __read_file(filepath, **kwargs)
cpts = __read_file(file, **kwargs)

cpts = _check_mandatory_column_presence(
cpts, MANDATORY_DISCRETE_DATA_COLUMNS, column_mapper
Expand Down Expand Up @@ -327,11 +327,10 @@ def read_nlog_cores(file: str | WindowsPath) -> BoreholeCollection:
:class:`~geost.borehole.BoreholeCollection`
:class:`~geost.borehole.BoreholeCollection`
"""
filepath = Path(file)
if filepath.suffix == ".xlsx":
nlog_cores = pd.read_excel(filepath)
if Path(file).suffix == ".xlsx":
nlog_cores = pd.read_excel(file)
else:
nlog_cores = __read_file(filepath)
nlog_cores = __read_file(file)

nlog_cores.rename(
columns={
Expand Down

0 comments on commit b7aa71a

Please sign in to comment.