Spaces:
Sleeping
Sleeping
Download export/qa_csv.py from Corin1998/IR_PR_PilotPro: direct link, hf CLI and curl.
- Browser
- Download file 648 Bytes
-
https://huggingface.co/spaces/Corin1998/IR_PR_PilotPro/resolve/main/export/qa_csv.py
- Command line
-
hf download hf://spaces/Corin1998/IR_PR_PilotPro/export/qa_csv.py
-
curl -L -o qa_csv.py https://huggingface.co/spaces/Corin1998/IR_PR_PilotPro/resolve/main/export/qa_csv.py
648 Bytes
| # export/qa_csv.py | |
| from __future__ import annotations | |
| from typing import List, Dict, Tuple | |
| import csv, os | |
| def save_qa_csv(qa_list: List[Dict], links: List[str], path: str) -> None: | |
| os.makedirs(os.path.dirname(path), exist_ok=True) | |
| with open(path, "w", encoding="utf-8-sig", newline="") as f: | |
| w = csv.writer(f, quoting=csv.QUOTE_ALL) | |
| w.writerow(["Q", "A"]) | |
| for item in qa_list: | |
| q = item.get("q") or item.get("Q") or "" | |
| a = item.get("a") or item.get("A") or "" | |
| # 改行はCSV内に残してExcelでも読めるようにする(QUOTE_ALLで安全) | |
| w.writerow([q, a]) | |