Useful for extracting files with different file types
from pathlib import Path
def read_tabular_file(path):
path = Path(path)
ext = path.suffix.lower()
if ext == ".csv":
df = pd.read_csv(path)
elif ext in [".txt", ".dat"]:
# Most TEA .dat/.txt files are pipe- or tab-delimited
# Start with pipe, adjust if needed
df = pd.read_csv(path, sep="|")
else:
raise ValueError(f"Unsupported file type: {ext}")
return df