How to send user input/arguments to a python script

Eight Stars

How to send user input/arguments to a python script

Hi,

I came across a scenario where the required parameters must be sent to python script in talend and the python script is being called by using tsystem component.

What my analysis is -> to store the parameters/user-input in a context and call the context variables in tsystem component.....

Can you pls let me know if this is approach is correct... 

Thanks,

Ankit

Community Manager

Re: How to send user input/arguments to a python script

This seems like an entirely reasonable approach. Just keep in mind that when using the tSystem component, you are essentially sending a Java String to the terminal. So when building your command with parameters, think about building a Java String that represents that command. For example....

 

If you are wanting to search a directory for txt files in one run and jpeg files in another, you could parameterise your extension name in a context variable called "fileExtension", then use it in a tSystem like below...

"cmd /c dir *." + context.fileExtension
Eight Stars

Re: How to send user input/arguments to a python script

I ll give it a try and get back to you on this...
Thanks.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads