Spaces:
Sleeping
Sleeping
Download scripts/extract_pdf.py from HackathonAma/renal-ai-backend: direct link, hf CLI and curl.
- Browser
- Download file 576 Bytes
-
https://huggingface.co/spaces/HackathonAma/renal-ai-backend/resolve/main/scripts/extract_pdf.py
- Command line
-
hf download hf://spaces/HackathonAma/renal-ai-backend/scripts/extract_pdf.py
-
curl -L -o extract_pdf.py https://huggingface.co/spaces/HackathonAma/renal-ai-backend/resolve/main/scripts/extract_pdf.py
576 Bytes
| from pypdf import PdfReader | |
| import os | |
| pdf_path = r"c:\Users\HP\Desktop\Bootcamp AMA\bootcamp-ama.pdf" | |
| output_path = r"c:\Users\HP\Desktop\Bootcamp AMA\bootcamp-ama-text.txt" | |
| try: | |
| reader = PdfReader(pdf_path) | |
| text = "" | |
| for page in reader.pages: | |
| text += page.extract_text() + "\n" | |
| with open(output_path, "w", encoding="utf-8") as f: | |
| f.write(text) | |
| print(f"Successfully extracted text to {output_path}") | |
| print("--- CONTENT PREVIEW ---") | |
| print(text[:2000]) # Print first 2000 chars | |
| except Exception as e: | |
| print(f"Error: {e}") | |