From Thursday, July, 9, 3:00 PM Pacific,
our Community site will be in
read-only mode
through Sunday, July 12th.
Thank you for your patience.

How to send user input/arguments to a python script

Nine 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

Highlighted
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
Highlighted
Nine 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.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog