Download code/scripts/inspect_data.py from nonsodev/essay-coach: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/nonsodev/essay-coach/resolve/main/code/scripts/inspect_data.py
- Command line
-
hf download hf://nonsodev/essay-coach/code/scripts/inspect_data.py
-
curl -L -o inspect_data.py https://huggingface.co/nonsodev/essay-coach/resolve/main/code/scripts/inspect_data.py
1.29 kB
| """Print the columns, row counts and a sample row of every CSV on the essay-data volume.""" | |
| import modal | |
| app = modal.App("essay-coach-inspect") | |
| vol = modal.Volume.from_name("essay-data") | |
| image = modal.Image.debian_slim(python_version="3.11").pip_install("pandas", "openpyxl") | |
| def inspect(): | |
| import glob | |
| import os | |
| import pandas as pd | |
| for p in sorted(glob.glob("/data/**/*.csv", recursive=True)): | |
| try: | |
| df = pd.read_csv(p, low_memory=False) | |
| except Exception as e: | |
| print("==", p, "ERR", e); continue | |
| print("==", p.replace("/data/", ""), f"{os.path.getsize(p)/1e6:.0f} MB rows {len(df)}") | |
| print(" cols:", list(df.columns)[:40]) | |
| r = df.iloc[0] | |
| print(" row0:", {c: (str(v)[:60] + ("..." if len(str(v)) > 60 else "")) for c, v in r.items()}) | |
| for c in df.columns: | |
| if df[c].dtype == object and df[c].nunique() < 15: | |
| print(f" {c}: {df[c].value_counts().to_dict()}") | |
| print(open("/data/ELLIPSE-Corpus/README.md").read()[:1500]) | |
| for p in glob.glob("/data/**/*.zip", recursive=True): | |
| print("zip:", p, os.path.getsize(p)) | |
| def main(): | |
| inspect.remote() | |