Problems Facing Using Python Scope

Hi, still, the problem occurs in the sequence “Of Converting a 600-page PDF Table File to an Excel Table File (Execution Time Under 4 Minutes).” I have also attached the sequence flow and the script I am using. Any help will be great.

In The end, i was getting stuck on “Get Python Object” Activity


import pandas as pd.txt (462 Bytes)

@Haseeb_Farrukh

I dont see any return value in your python code…so there is nothing to convert back…

Please remove that get python object…you dont need it at all

Cheers

1 Like

Hi @Haseeb_Farrukh ,

What do you want to do with Python Code, I see you are already converted PDF into table using python script.

1 Like

@Haseeb_Farrukh ,

Get python Activity is not required so you may remove it as there is no return value in code.

1 Like

Hello @Haseeb_Farrukh , If yu need the log messages from the Pythonncode, then use “return” instead of “print”. NAd the the Get python object properties set as Object and Print the message using log messages like GetpyOutput.tostring.

import pandas as pd
import tabula

def extract_tables_to_excel(pdf_path, excel_path):
    """Extracts tables from PDF and saves them to Excel."""

    try:
        df = tabula.read_pdf(pdf_path, pages="all", multiple_tables=True)  # Read all tables
        with pd.ExcelWriter(excel_path) as writer:
            df.to_excel(writer, sheet_name="Extracted Tables", index=False)
       return "Extraction done successfully"
    except Exception as e:
       return f"Error extracting tables: {e}"

1 Like