Spaces:
Running on Zero
Running on Zero
Download src/data_ingestion.py from Evasim/Simple-Text-Classifier: direct link, hf CLI and curl.
- Browser
- Download file 657 Bytes
-
https://huggingface.co/spaces/Evasim/Simple-Text-Classifier/resolve/main/src/data_ingestion.py
- Command line
-
hf download hf://spaces/Evasim/Simple-Text-Classifier/src/data_ingestion.py
-
curl -L -o data_ingestion.py https://huggingface.co/spaces/Evasim/Simple-Text-Classifier/resolve/main/src/data_ingestion.py
657 Bytes
| import os | |
| import pandas as pd | |
| from datasets import load_dataset | |
| def download_and_save_ag_news(): | |
| # Create data folder if missing | |
| os.makedirs("data", exist_ok=True) | |
| print("⏳ Fetching ag_news from Hugging Face...") | |
| # Load from HF Hub | |
| dataset = load_dataset("fancyzhx/ag_news") | |
| # Convert training split to a DataFrame | |
| train_df = pd.DataFrame(dataset["train"]) | |
| # Save locally as a raw CSV | |
| output_path = "data/raw_dataset.csv" | |
| train_df.to_csv(output_path, index=False) | |
| print(f"✅ Success! ag_news dataset saved locally to: {output_path}") | |
| if __name__ == "__main__": | |
| download_and_save_ag_news() | |