Download src/com_func.py from treizh/oiv_ld_phenotyping: direct link, hf CLI and curl.
- Browser
- Download file 596 Bytes
-
https://huggingface.co/treizh/oiv_ld_phenotyping/resolve/main/src/com_func.py
- Command line
-
hf download hf://treizh/oiv_ld_phenotyping/src/com_func.py
-
curl -L -o com_func.py https://huggingface.co/treizh/oiv_ld_phenotyping/resolve/main/src/com_func.py
596 Bytes
| import pandas as pd | |
| def ensure_folder(forced_path, return_string: bool = True): | |
| path = forced_path.parent | |
| if path.is_dir() is False: | |
| path.mkdir(parents=True, exist_ok=True) | |
| return str(forced_path) if return_string is True else forced_path | |
| def read_dataframe(path, sep=";") -> pd.DataFrame: | |
| try: | |
| return pd.read_csv(filepath_or_buffer=str(path), sep=sep) | |
| except: | |
| return None | |
| def write_dataframe(df: pd.DataFrame, path, sep=";") -> pd.DataFrame: | |
| df.to_csv(path_or_buf=ensure_folder(path, return_string=True), sep=sep, index=False) | |
| return df | |