# Load file from local disk This article explains how to load PDF, Word, Excel, PowerPoint documents from local disk when using GroupDocs.Parser for Python via .NET. When the document file is located on the local disk, [GroupDocs.Parser](https://products.groupdocs.com/parser/python-net) allows you to load it using the `Parser` class constructor by specifying an absolute or relative path. The following code snippet shows how to load a document from a local disk: ## Load document by file path {{< tabs "example-1" >}} {{< tab "Python" >}} ```python from groupdocs.parser import Parser # Specify the file path (absolute or relative) file_path = "sample.docx" # Create an instance of Parser class with the file path with Parser(file_path) as parser: # Extract text from the document text_reader = parser.get_text() if text_reader is not None: # Print the extracted text print(text_reader.read_to_end()) else: print("Text extraction isn't supported for this format") ``` {{< /tab >}} {{< tab "sample.docx" >}} {{< tab-text >}} The following sample file is used in this example: [sample.docx](https://docs.groupdocs.com/parser/python-net/_sample_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/sample.docx) {{< /tab-text >}} {{< /tab >}} {{< tab "load-document-by-file-path.txt" >}} ```text Supply Agreement | Harbor Lane Provisions and Northwind Coffee Roasters | Confidential Supply Agreement Harbor Lane Provisions and Northwind Coffee Roasters 1. Parties Buyer: Harbor Lane Provisions, 18 Quayside Road, Port Ellery, represented by Lena Park, Procurement Lead. Supplier: Northwind Coffee Roasters, 4 Roastery Lane, Millbrook, represented by Alex Chen. This agreement takes effect on 12 January 2026 and replaces the agreement of January 2023. [TRUNCATED] ``` [Download full output](https://docs.groupdocs.com/parser/python-net/_output_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/example-1/load-document-by-file-path.txt) {{< /tab >}} {{< /tabs >}} ## Load document with absolute path {{< tabs "example-2" >}} {{< tab "Python" >}} ```python from groupdocs.parser import Parser # Specify an absolute file path file_path = "sample.pdf" # Create an instance of Parser class with Parser(file_path) as parser: # Get document info doc_info = parser.get_document_info() print(f"File type: {doc_info.file_type.file_format}") print(f"Page count: {doc_info.page_count}") print(f"File size: {doc_info.size} bytes") ``` {{< /tab >}} {{< tab "sample.pdf" >}} {{< tab-text >}} The following sample file is used in this example: [sample.pdf](https://docs.groupdocs.com/parser/python-net/_sample_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/sample.pdf) {{< /tab-text >}} {{< /tab >}} {{< tab "load-document-with-absolute-path.txt" >}} ```text File type: Portable Document Format File Page count: 4 File size: 622772 bytes ``` [Download full output](https://docs.groupdocs.com/parser/python-net/_output_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/example-2/load-document-with-absolute-path.txt) {{< /tab >}} {{< /tabs >}} ## Batch processing multiple files {{< tabs "example-4" >}} {{< tab "Python" >}} ```python from groupdocs.parser import Parser import os def process_files_from_directory(directory_path): """Process all supported documents in a directory""" # Get all files in the directory for filename in sorted(os.listdir(directory_path)): file_path = os.path.join(directory_path, filename) # Skip if not a file if not os.path.isfile(file_path): continue try: print(f"\nProcessing: {filename}") # Create parser instance with Parser(file_path) as parser: # Get document info doc_info = parser.get_document_info() print(f" Type: {doc_info.file_type.file_format}") print(f" Pages: {doc_info.page_count}") # Extract text text_reader = parser.get_text() if text_reader is not None: text = text_reader.read_to_end() print(f" Characters: {len(text)}") except Exception as e: print(f" Error: {e}") # Process every document in the ./documents folder process_files_from_directory("documents") ``` {{< /tab >}} {{< tab "documents" >}} {{< tab-text >}} The following sample files are used in this example: [annual-report.pdf](https://docs.groupdocs.com/parser/python-net/_sample_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/documents/annual-report.pdf), [service-agreement.docx](https://docs.groupdocs.com/parser/python-net/_sample_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/documents/service-agreement.docx), [inventory.xlsx](https://docs.groupdocs.com/parser/python-net/_sample_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/documents/inventory.xlsx), [product-catalog.pptx](https://docs.groupdocs.com/parser/python-net/_sample_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/documents/product-catalog.pptx) {{< /tab-text >}} {{< /tab >}} {{< tab "process-files-from-directory.txt" >}} ```text Processing: annual-report.pdf Type: Portable Document Format File Pages: 4 Characters: 4570 Processing: inventory.xlsx Type: Microsoft Excel Open XML Spreadsheet Pages: 2 Characters: 4352 [TRUNCATED] ``` [Download full output](https://docs.groupdocs.com/parser/python-net/_output_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/process_files_from_directory/process-files-from-directory.txt) {{< /tab >}} {{< /tabs >}} ## Error handling It's good practice to handle potential errors when loading files: {{< tabs "example-5" >}} {{< tab "Python" >}} ```python from groupdocs.parser import Parser import os def safe_load_document(file_path): """Safely load a document with error handling""" # Check if file exists if not os.path.exists(file_path): print(f"Error: File not found - {file_path}") return None try: # Create parser instance parser = Parser(file_path) print(f"Document loaded successfully: {file_path}") return parser except Exception as e: print(f"Error loading document: {e}") return None # Try to load a document parser = safe_load_document("sample.pdf") if parser is not None: try: # Extract data text_reader = parser.get_text() if text_reader is not None: print(text_reader.read_to_end()) else: print("Text extraction isn't supported for this format") finally: # Always release the parser parser.dispose() ``` {{< /tab >}} {{< tab "sample.pdf" >}} {{< tab-text >}} The following sample file is used in this example: [sample.pdf](https://docs.groupdocs.com/parser/python-net/_sample_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/sample.pdf) {{< /tab-text >}} {{< /tab >}} {{< tab "safe-load-document.txt" >}} ```text Document loaded successfully: sample.pdf Investor relations Annual Report 2025 | Port Ellery Annual Report 2025 1. Overview Harbor Lane Provisions supplies specialty food to 1,265 independent grocers, cafes and restaurants from its [TRUNCATED] ``` [Download full output](https://docs.groupdocs.com/parser/python-net/_output_files/developer-guide/advanced-usage/loading/load-file-from-local-disk/safe_load_document/safe-load-document.txt) {{< /tab >}} {{< /tabs >}} ## More resources ### GitHub examples You may find more code examples in our GitHub repository: * [GroupDocs.Parser for Python via .NET examples](https://github.com/groupdocs-parser/GroupDocs.Parser-for-Python-via-.NET) ### Free online document parser Along with the full-featured library, we provide a free online document parser app. You are welcome to extract data from PDF, DOCX, XLSX, and more with our [Free Online Document Parser App](https://products.groupdocs.app/parser).