0 votes
1 view
in RPA by (11.8k points)

Here is an image showing Python scope activity:

Image shows python scope activity

I am trying to execute a script in UIPath using Python scope, Python load activity, invoke python method and get python object which is mentioned below:

The execution is getting completed without any errors/exceptions. But there is no .xlsx file written. The code is not getting executed/ the arguments are not passed correctly. Kindly help.

import sys

import pandas as pd

import xlsxwriter

def excel_data (arg1,arg2,arg3,arg4):

    df = pd.DataFrame({‘SODA RISK’: [arg1,arg2,arg3,arg4]}) 

    writer = pd.ExcelWriter(‘try_python.xlsx’, engine=‘xlsxwriter’) 

    df.to_excel(writer,sheet_name=‘Sheet1’) 

    writer.save()

1 Answer

0 votes
by (27.7k points)

I think the problem is there because you did not provide a custom path, so the file most likely gets created in the NuGet package folder (your user's name and the package versions most likely will be different):

C:\Users\foo\.nuget\packages\uipath.python.activities\1.1.6863.33404\lib\net452
To fix this what you can do is change the code so that the full path can be provided as an argument:

import sys
import pandas as pd
import xlsxwriter

def excel_data (fullPath, arg1, arg2, arg3, arg4):
    df = pd.DataFrame({'SODA RISK': [arg1,arg2,arg3,arg4]})
    writer = pd.ExcelWriter(fullPath, engine='xlsxwriter')
    df.to_excel(writer,sheet_name='Sheet1')
    writer.save()

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...