File Content Extraction 25.1
Filter SDK Python Programming Guide

# Metadata Examples

If you want to process both standardized and non-standardized metadata elements, you can iterate over metadata elements without checking an element's standard key – both standardized and non-standardized metadata can be handled in the same way. However, standardization provides a way to handle common types of metadata - using the same code for all file formats. Below is an illustrative example.

Copy

    # Open a document
    with session.open(file_path) as doc:

        # Iterate over metadata fields
        for element in doc.metadata:

            # Skip non-standard fields
            if element.standard_key == kv.MetadataKey.Other:
                continue

            # Do something with the standardized WordCount field
            if element.standard_key == kv.MetadataKey.WordCount:
                print(f"The word count is {element.value}")

The following example demonstrates how to take advantage of field standardization, but also avoid processing a metadata field more than once.

Copy

    # Open a document
    with session.open(file_path) as doc:

        # Iterate over metadata fields
        for element in doc.metadata:

            # Process standardized elements where possible but also process
            # non-standard elements that have no standardized alternative.
            # Ignore duplicate elements output for backwards compatibility.

            if not element.has_standard_alternative and not element.is_superseded:
                process(element)

Copyright 1997-2024 Open Text
Version 25.1 | Last updated January 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: File Content Extraction 25.1

Topic Title: Metadata Examples