Spaces:
Sleeping
Sleeping
Crs-Lionel
Claude Opus 4.8
Initial commit: FilezKit backend + frontend, dockerized for HF Spaces
82a25a8 Download backend/app/workers/csv_to_json.py from tech-ties/filezkit-backend: direct link, hf CLI and curl.
- Browser
- Download file 864 Bytes
-
https://huggingface.co/spaces/tech-ties/filezkit-backend/resolve/main/backend/app/workers/csv_to_json.py
- Command line
-
hf download hf://spaces/tech-ties/filezkit-backend/backend/app/workers/csv_to_json.py
-
curl -L -o csv_to_json.py https://huggingface.co/spaces/tech-ties/filezkit-backend/resolve/main/backend/app/workers/csv_to_json.py
864 Bytes
| import pandas as pd | |
| from app.core.celery_app import celery_app | |
| from app.db.session import SessionLocal | |
| from app.workers.conversion_helpers import ( | |
| complete_job, | |
| fail_job, | |
| outputs_dir, | |
| start_file_job | |
| ) | |
| def csv_to_json_task(job_id: int): | |
| db = SessionLocal() | |
| job = None | |
| try: | |
| job, input_path = start_file_job(db, job_id) | |
| if not job: | |
| return | |
| df = pd.read_csv(input_path) | |
| output_path = ( | |
| outputs_dir() | |
| / | |
| f"csv_to_json_{job_id}.json" | |
| ) | |
| df.to_json( | |
| output_path, | |
| orient="records", | |
| indent=2, | |
| force_ascii=False | |
| ) | |
| complete_job(db, job, output_path) | |
| except Exception as e: | |
| fail_job(db, job, "CSV To JSON", job_id, e) | |
| finally: | |
| db.close() | |