How to pass data table as argument in python invoke method

i need to pass data table variable to python script , i getting below exception.

Main.xaml: (2) : error BC36914: Cannot infer an element type, and Option Strict On does not allow ‘Object’ to be assumed. Specifying the type of the array might correct this error.

This error is because it can’t know the datatype of your array. It’s not because you have put DBTable in there (although I’m not sure if this will work).

Try this in your expression:

New Object(){DBTable,inputExcelTable,UseExceptedRatio,strOutputPath}

By the way, this solution is easily found by searching the forum for the error message “cannot infer an element type”

thank you for replay

after using below line of code ,i am getting this error
New Object(){DBTable,inputExcelTable,UseExceptedRatio,strOutputPath}

i am sure there is no exception from python , i tested python code in vs code

import traceback
import pandas as pd
import datetime


outPath = r'C:\Users\userName\Documents\Test\Output.xlsx'
UersExceptedRatio = 75

# Logic for Text Ratio method
def text_ratio(Source, Destination):
    lstDBKeywords = Source.split(" ")
    lstExcelKeywords = Destination.split(" ")

    matched_key = 0
    for keyword in lstDBKeywords:
        for Exkey in lstExcelKeywords:
            if Exkey == keyword:
                matched_key += 1
    percentage = (matched_key / len(lstDBKeywords)) * 100
    return percentage

# Logic for textMatcher Method
def textMatcher(DBTable, inputExcelTable, UersExceptedRatio, outPath):
    Method_Status = "Success"

        UersExceptedRatio = int(UersExceptedRatio)
        for _, rowDBTable in DBTable.iterrows():
            counter += 1
            print("counter-- ", counter, "----- ", str(rowDBTable['Name']).replace(',', ''))
            # ScrapingList Input Excel Loop
            for _, rowinputExcelTable in inputExcelTable.iterrows():
    except Exception as methoderror:
        Method_Status = "Address Matching Python Script Error Messasge : "+str(methoderror)+" : "+traceback.format_exc()
        return Method_Status

# this textMatcher method is for Dev testing only.
#textMatcher(DBTable, inputExcelTable, UersExceptedRatio, outPath)

except Exception as e:
exception_message = traceback.format_exc()
print(“An error occurred:”, str(e))

Because the array elements are now all datatype Object, you may have to convert them from object back to their actual datatype - within the the python code. I don’t really know python, so I can’t help beyond that suggestion.


You are passing a dotnet datatable and expecting in python to be a pandas table…

It might not work like that…try to weite the datatable to an excel and in python read the excel instead of passing…

After that you can delete

Or you need to serialize the datatable and then deserialize in python…I feel writing to excel and reading using python would be easy

And you can see the exact exception when you open the exception details from the locals panel in UiPath when you see such an error

Hope this helps