{"id":6573,"library":"compoundfiles","title":"Compound Files","description":"Compoundfiles is a Python library for parsing and reading OLE Compound Documents, a legacy file format used by Microsoft applications like MS Office before Office 2007. It provides a simple API to access streams and storages within these files. The current stable version is 0.3, last released in 2017, indicating the project is in a maintenance or abandoned state with no active development.","status":"maintenance","version":"0.3","language":"en","source_language":"en","source_url":"https://github.com/remy-fr/compoundfiles","tags":["file parsing","OLE","compound document","legacy","microsoft office"],"install":[{"cmd":"pip install compoundfiles","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"CompoundFile","correct":"from compoundfiles import CompoundFile"}],"quickstart":{"code":"\nimport os\nfrom compoundfiles import CompoundFile\n\n# IMPORTANT: Replace 'path/to/your/ole_document.doc' with the actual path\n# to an OLE Compound Document (e.g., old .doc, .xls, .ppt files).\n# This library is for reading existing OLE files.\n# A sample OLE file (e.g., an old .doc) is required for this example to run meaningfully.\nfile_path = os.environ.get('OLE_FILE_PATH', './example.doc') # Placeholder for agent\n\nif not os.path.exists(file_path):\n    print(f\"Warning: OLE file not found at '{file_path}'. Please provide a valid path.\")\n    print(\"Example usage requires an actual OLE Compound Document file.\")\n    print(\"You can provide it via OLE_FILE_PATH environment variable or replace the hardcoded path.\")\nelse:\n    try:\n        with CompoundFile(file_path) as cf:\n            print(f\"Successfully opened OLE Compound Document: {file_path}\")\n            print(\"\\nRoot entries:\")\n            for entry in cf.listdir('/'):\n                print(f\"- {entry}\")\n\n            # Example: Try to read a specific stream if it exists\n            # 'WordDocument' is a common stream name in OLE Word documents.\n            if 'WordDocument' in cf.listdir('/'):\n                with cf.open('WordDocument') as stream:\n                    # Read a portion of the stream (actual content is often binary/complex)\n                    content = stream.read(50)\n                    print(f\"\\nContent of '/WordDocument' stream (first 50 bytes): {content!r}\")\n            else:\n                print(\"\\nNo 'WordDocument' stream found. Listing other common streams if available...\")\n                for common_stream in ['Workbook', 'PowerPoint Document', 'Contents']: # Add other common stream names\n                    if common_stream in cf.listdir('/'):\n                        print(f\"Found stream: '{common_stream}'\")\n\n    except Exception as e:\n        print(f\"\\nError processing OLE file '{file_path}': {e}\")\n        print(\"Ensure the file is a valid OLE Compound Document and not corrupted.\")\n","lang":"python","description":"This quickstart demonstrates how to open an OLE Compound Document, list its root entries (streams and storages), and attempt to read content from a common stream like 'WordDocument'. It requires a path to an existing OLE file to function properly."},"warnings":[{"fix":"For modern Office files (.docx, .xlsx, .pptx), use libraries like `python-docx`, `openpyxl`, or `python-pptx` instead.","message":"This library is designed for reading legacy OLE Compound Documents (e.g., .doc, .xls, .ppt files from Office 97-2003). It does NOT support modern Office Open XML (OOXML) formats like .docx, .xlsx, or .pptx.","severity":"gotcha","affected_versions":"0.1 - 0.3"},{"fix":"Proceed with caution. Consider if this library meets your project's long-term maintenance and security requirements. Test thoroughly if deploying in a production environment.","message":"The `compoundfiles` library has not been updated since 2017 (version 0.3). It is not actively maintained, which means there may be unpatched bugs, security vulnerabilities, or compatibility issues with newer Python versions or operating systems.","severity":"gotcha","affected_versions":"0.3"},{"fix":"Always wrap file operations in `try...except` blocks to catch potential `CompoundFileError` or other exceptions, and provide robust error handling for user-supplied or untrusted files.","message":"Parsing malformed or corrupted OLE Compound Documents can lead to exceptions or unexpected behavior, as the library may not handle all edge cases gracefully.","severity":"gotcha","affected_versions":"0.1 - 0.3"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}