# Media\_input.transform() fails to preview

**URL:** <https://community.palantir.com/t/media-input-transform-fails-to-preview/5960>\
**Category:** Ask the Community\
**Tags:** code-repositories, media-sets\
**Created:** [February 4, 2026, 10:28pm UTC](https://community.palantir.com/t/media-input-transform-fails-to-preview/5960 "2026-02-04T22:28:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeStrap](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/codestrap/32/138_2.png) [@CodeStrap](https://community.palantir.com/u/CodeStrap)\
**Post date:** [February 4, 2026, 10:28pm UTC](https://community.palantir.com/t/media-input-transform-fails-to-preview/5960/1 "2026-02-04T22:28:55Z")

</div>

Calling the transform method yeilds the following error in preview:

```auto
A PreviewMediaSetInput object does not have an attribute transform. Please check the spelling and/or the datatype of the object.

```

It builds just fine though. Full code below with RIDs replaced.

```auto
from transforms.api import transform, Output, TransformOutput
from transforms.mediasets import MediaSetInput, MediaSetInputParam

@transform(
    media_input=MediaSetInput("<My_RID>"),
    output=Output("<My_RID>"),
)
def compute(ctx, media_input: MediaSetInputParam, output: TransformOutput):
    """
    Extract text from each page of PDFs in the media set.

    Output columns:
    - page_number: The page number (zero-indexed)
    - extracted_text: Text extracted from the page via OCR
    - media_item_rid: RID of the media item (document)
    - path: Path of the media item in the media set
    - media_reference: Reference to the media item
    """
    # Create a MediaSetInputTransform instance and apply OCR with page_per_row
    # This will create one row per page with the page number and extracted text
    transform_instance = media_input.transform()

    # Use OCR to extract text from PDFs, returning one row per page
    result_df = transform_instance.ocr(
        return_structure="page_per_row", # One row per page
        languages=["eng"], # English language for OCR
        suppress_errors=True, # Continue processing even if some pages fail
    )

    # The resulting DataFrame will have columns:
    # - media_item_rid: RID of the document
    # - path: Path of the document in the media set
    # - media_reference: Reference column for the media item
    # - page_number: Page number (zero-indexed)
    # - extracted_text: Text extracted from that page

    # Define column type classes to preserve media reference
    column_typeclasses = {"media_reference": [{"kind": "reference", "name": "media_reference"}]}

    # Write the result to the output dataset
    output.write_dataframe(result_df, column_typeclasses=column_typeclasses)

```

---

<div class="post-metadata">

**Author:** ![wfann](https://avatars.discourse-cdn.com/v4/letter/w/7ba0ec/32.png) [@wfann](https://community.palantir.com/u/wfann)\
**Post date:** [February 4, 2026, 10:32pm UTC](https://community.palantir.com/t/media-input-transform-fails-to-preview/5960/2 "2026-02-04T22:32:25Z")

</div>

Hi unfortunately not all media set operations are supported in preview at this time, including the transform interface.

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/system/32/3_2.png) [@system](https://community.palantir.com/u/system)\
**Post date:** [May 7, 2026, 6:32am UTC](https://community.palantir.com/t/media-input-transform-fails-to-preview/5960/3 "2026-05-07T06:32:37Z")

</div>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.
