Spaces:
Runtime error
Runtime error
Download utils.py from dipenvekaria/GraphRAG: direct link, hf CLI and curl.
- Browser
- Download file 532 Bytes
-
https://huggingface.co/spaces/dipenvekaria/GraphRAG/resolve/main/utils.py
- Command line
-
hf download hf://spaces/dipenvekaria/GraphRAG/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/dipenvekaria/GraphRAG/resolve/main/utils.py
532 Bytes
| import fitz | |
| import logging | |
| logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| logger = logging.getLogger(__name__) | |
| def extract_pdf_text(file_path): | |
| try: | |
| text = "" | |
| with fitz.open(file_path) as pdf: | |
| for page in pdf: | |
| page_text = page.get_text("text") | |
| text += page_text if page_text else "" | |
| return text | |
| except Exception as e: | |
| logger.error(f"Error extracting text from PDF {file_path}: {str(e)}") | |
| raise |