Invoke Python method Argument Error

I guys,

I have this python method to write tables in excel.

def create_pivot_table(Dir):
file1 = open(r’C:\Users**\myfile2.txt’,“w”)
file1.write(Dir)
file1.close()
df = pd.read_excel(open(Dir,‘rb’),“Hoja1”)
pivot_baja=df[df[‘Texto’].str.contains(“BAJA”)==True].pivot_table(index=‘Cuenta’, values=’ Importe en ML’, aggfunc=‘sum’)
pivot_Aplica=df[df[‘Texto’].str.contains(“Aplica”)==True].pivot_table(index=‘Cuenta’, values=’ Importe en ML’, aggfunc=‘sum’)
pivot_add=df[(df[‘Texto’].str.contains(“BAJA”)==False) & (df[‘Texto’].str.contains(“Aplica”)==False) & (df[‘Texto’].str.contains(“baja”)==False) ].pivot_table(index=‘Cuenta’, values=’ Importe en ML’, aggfunc=‘sum’)
book = load_workbook(dir)
writer = pd.ExcelWriter(dir, engine=‘openpyxl’)
writer.book=book
pivot_Aplica.to_excel(writer, sheet_name=“Aplicaciones”)
pivot_add.to_excel(writer,sheet_name=“Adiciones”)
pivot_baja.to_excel(writer, sheet_name=“bajas”)
writer.save()
writer.close()

and the activity is giving me this exception:

"RemoteException wrapping System.InvalidOperationException: Error invoking Python method —> RemoteException wrapping System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: TypeError : expected str, bytes or os.PathLike object, not builtin_function_or_method "

the argument of the activity is {“workbook.xlsx”}.

when i use the script by its own i don’t have any problems

Solve it, the lower key dir variables where the problem

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