Using code in load python script

Hi everyone,
How to use code input in load python script activity, should I just paste entire python code as argument, my code basically convert all data in text file to excel. How do I run it using the Code argument as input.
Thanks in advance

Hi,

Please refer the below forum link you could find one example from our UiPath developers community.

Regards,
Kirankumar.

@Daniyal_Tahir

Also you can refer youtube videos on this question

Hope this may help you

Thanks

Can I run the Python Code script through python.exe, taking start process activity

Hi

There are two way to run a Python script

  1. If the script has to executed and the output of that script is not given as a input to UiPath process then
    Write the script in a notepad and save as .py file

  2. Then use Notepad again and create a bat file
    Like
    “Your Python exe filepath” “your py filepath”
    And save it as .bat file

  3. Now use a START PROCESS activity in UiPath where pass the filepath of that bat file as input

This will just run the script and we won’t be able to use the output of that script

But as you said it will convert to excel file
That excel file can be read and it’s data can be still fetched and read with the EXCEL APPLICATION SCOPE and READ RANGE activity
Which can be further used with UiPath projects

Or

If you want to use Python activity and I run the scrip and use it’s output by passing it as argument

Then refer this doc on how to use Python activity
@Daniyal_Tahir

Hope this would help you resolve this

Cheers @Daniyal_Tahir

@Palaniyappan
Can you please show me an example how can I create bat file? I already have the notepad file saved as .py file.
Thanks in advance

1 Like

Fine

Open a notepad and mention like this

“Path where your Python exe is stored\python.exe” “Path where your Python script is stored\script name.py”

For example

“C:\Users\Ron\AppData\Local\Programs\Python\Python39\python.exe” “C:\Users\Ron\Desktop\Test\countdown.py”

That .py file is the file where you have mentioned the script

And save the file with extension as .bat

That file and it’s filepath can be mentioned in start process activity

Cheers @Daniyal_Tahir

@Palaniyappan
I am trying to run the batch file, but it gets closed everytime in blink of an eye and is not generating any output.

Pls check once with that Python script and see whether it is working as expected by running it in a IDLE

And if it is working fine then
Run the bat file and open task manger and search for Python, see whether it is running or not in background

When we run a Python script in bat file it will open the cmd window for a second and close it but it will be running in background

Pls check that

@Daniyal_Tahir

@Palaniyappan yes its working perfectly fine manually and is also generating the excel sheet I wanted, but its getting closed every-time I run it through the bot and is not generating any excel file as output either

Can I see the bat file If possible with a screenshot
instead let’s try with this method @Daniyal_Tahir

@Palaniyappan
when executing through the bot it is unable to read the text file provided in code, when executing manually its working fine.

It worked…all i had to do was to place the text file on the project folder.
Thanks to all who helped

Glad @Daniyal_Tahir

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