Spaces:
Sleeping
Sleeping
Download pdf_utils_bak2108.py from prithvi55/talk2data: direct link, hf CLI and curl.
- Browser
- Download file 372 Bytes
-
https://huggingface.co/spaces/prithvi55/talk2data/resolve/main/pdf_utils_bak2108.py
- Command line
-
hf download hf://spaces/prithvi55/talk2data/pdf_utils_bak2108.py
-
curl -L -o pdf_utils_bak2108.py https://huggingface.co/spaces/prithvi55/talk2data/resolve/main/pdf_utils_bak2108.py
372 Bytes
| import pandas as pd | |
| try: | |
| import PyPDF2 | |
| except ImportError: | |
| PyPDF2 = None | |
| def extract_pdf_text(uploaded_file): | |
| if PyPDF2 is None: | |
| return None, "PyPDF2 not installed. PDF support unavailable." | |
| pdf_reader = PyPDF2.PdfReader(uploaded_file) | |
| text = "\n".join(page.extract_text() or '' for page in pdf_reader.pages) | |
| return text, None | |