Extract Data from Attachments and ZIP Archives

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Parser MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-parser -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-parser/parser-net-mcp:latest
Folders, licensing and more →

Use container extraction to open archive-like formats (ZIP, RAR, TAR), Outlook stores (PST/OST), PDF portfolios, and email attachments, then parse their contents.

Extract and parse attachments

from groupdocs.parser import Parser
from groupdocs.parser.exceptions import UnsupportedDocumentFormatException

with Parser("./archive.zip") as parser:
    attachments = parser.get_container()
    if attachments is None:
        print("Container extraction isn't supported for this format.")
    else:
        for item in attachments:
            print(item.file_path)
            try:
                with item.open_parser() as attachment_parser:
                    reader = attachment_parser.get_text()
                    print(reader.read_to_end() if reader is not None else "No text available.")
            except UnsupportedDocumentFormatException:
                print("Item format is not supported.")

The following sample file is used in this example: archive.zip

finance/invoice-HLP-2025-0412.pdf
                                                                                           INVOICE


   FROM                                                                     Invoice Number      HLP-2025-0412
   Northwind Coffee Roasters                                                Invoice Date        4 November 2025
   4 Roastery Lane, Millbrook                                               Due Date            4 December 2025
   alex.chen@northwindroa
[TRUNCATED]

Download full output

Steps

  1. Instantiate Parser for the container file.
  2. Call get_container() to list ContainerItem entries.
  3. For each item, use open_parser() to create a Parser over the embedded content and reuse standard extraction methods (get_text, get_images, get_metadata, etc.).
  4. Handle unsupported formats with UnsupportedDocumentFormatException.

For working with attachments in complex scenarios (nested containers, load options), see the advanced containers guide.