Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in RPA by (12.7k 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 (29.5k 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()

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...