Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TSV files in file_io #341

Merged
merged 4 commits into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fuse/utils/file_io/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def save_dataframe(df: pd.DataFrame, filename: str, **kwargs: dict) -> None:

assert file_type in [
"csv",
"tsv",
"hd5",
"hdf5",
"hdf",
Expand All @@ -304,6 +305,8 @@ def save_dataframe(df: pd.DataFrame, filename: str, **kwargs: dict) -> None:
df.to_pickle(filename, **kwargs)
elif file_type == "csv":
df.to_csv(filename, **kwargs)
elif file_type == "tsv":
df.to_csv(filename, sep="\t" ** kwargs)
elif file_type in ["hd5", "hdf5", "hdf"]:
df.to_hdf(filename, **kwargs)
elif file_type == "xslx":
Expand All @@ -322,6 +325,7 @@ def read_dataframe(filename: str) -> pd.DataFrame:

assert file_type in [
"csv",
"tsv",
"hd5",
"hdf5",
"hdf",
Expand All @@ -334,6 +338,8 @@ def read_dataframe(filename: str) -> pd.DataFrame:
df = pd.read_pickle(filename)
elif file_type == "csv":
df = pd.read_csv(filename)
elif file_type == "tsv":
df = pd.read_csv(filename, sep="\t")
elif file_type in ["hd5", "hdf5", "hdf"]:
df = pd.read_hdf(filename)
elif file_type == "xslx":
Expand Down
Loading