BALM-benchmark / convert_csv_to_hf_dataset.py
aryopg's picture
Upload 42 files
a6869dd verified
raw
history blame
882 Bytes
import os
import pandas as pd
from datasets import load_dataset
def main():
data_dirs = [
"./BindingDB_filtered",
"./CATS",
"./HIF2A",
"./HSP90",
"./LeakyPDB",
"./MCL1",
"./Mpro",
"./SYK",
]
for data_dir in data_dirs:
print(data_dir)
filepath = os.path.join(data_dir, "data.csv")
df = pd.read_csv(filepath)
# Add Index column, make sure it's the left most column
if "Index" not in df.columns:
df["Index"] = df.index
df = df[["Index"] + [col for col in df.columns if col != "Index"]]
df.to_csv(filepath, index=False)
dataset = load_dataset("csv", data_files=filepath, delimiter=",")
print(dataset)
print("Saving to disk...")
dataset.save_to_disk(data_dir)
if __name__ == "__main__":
main()