Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
i created this job tFileList------->tSystem------------>tExtractDelimetedFields
in order to iterates on files and folders with tFileList, get ((String)globalMap.get("tFileList_1__CURRENT_FILEPATH")) as result and use this result in tSytem as argument to my script Python.
rq : my script python allow me to read DBF file.
I used this command : "python \"liredbf.py" + ((String)globalMap.get("tFileList_1__CURRENT_FILEPATH")) but i got this error
python: can't open file 'liredbf.py null': [Errno 2] No such file or directory
How can i get the result of tFileList to use it as argument for my Script Python.
Thank you in advance
cordially.
ok, and on original post, and on picture - I saw wrong name of variable
correct -
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
on picture and in original post -
((String)globalMap.get("tFileList_1__CURRENT_FILEPATH"))
please double-check
it also my mistake, because I copy past from Your post, but this is could be reason for NullPointer error
generally You can test:
"python \"liredbf.py\" " + ((String)globalMap.get("tFileList_1__CURRENT_FILEPATH"))
look for close \"and space after liredbf.py
or You can switch mode of tSystem to Use Array and pass each parameter as separate line
also You can omit open and close \" (not sure, but usually they need only if filename with space)
Thanks vapukov for your response.
I try to do the second solution, i don't get an error but also i don't get any result.
context.PathPython is: "python \"C:\\Users\\Ines\\Desktop\\Python\\lirealldbf.py"
context.var is : ((String)globalMap.get("tFileList_1__CURRENT_FILEPATH"))
i do this test
I think my script python can't read this path ((String)globalMap.get("tFileList_1__CURRENT_FILEPATH")) so it can't open the file !
it wrong construction
try this - first without any context variables
row by row
1) "python"
2) "C:\\Users\\Ines\\Desktop\\Python\\lirealldbf.py"
3) ((String)globalMap.get("tFileList_1__CURRENT_FILEPATH"))
or
1) "cmd"
2) "/c"
3) "python" 4) "C:\\Users\\Ines\\Desktop\\Python\\lirealldbf.py" 5) ((String)globalMap.get("tFileList_1__CURRENT_FILEPATH"))
I do not have access today for windows Talend Studio and not remember it accept first variant or not (on mac I use 1st)
also - check is python in path or not - when windows start new process for tSystem, it is not fact all PATH variables will be passed, so try to add full path to Python
I've changed my construction but i got this error :
Exception in component tSystem_1
java.lang.NullPointerException
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at local_project.secondtest_0_1.SecondTest.tFileList_1Process(SecondTest.java:1097)
at local_project.secondtest_0_1.SecondTest.runJobInTOS(SecondTest.java:2284)
at local_project.secondtest_0_1.SecondTest.main(SecondTest.java:2132)
2017-05-11 10:42:22|Kc8fjP|Kc8fjP|Kc8fjP|LOCAL_PROJECT|SecondTest|Default|6|Java Exception|tSystem_1|java.lang.NullPointerException:null|1
[statistics] disconnected
In my code Python i wrote this path f1 =sys.argv[1] to read the file as an argument and i got a result when i execute my script python on command ligne but with talend doesn't work !
show the current pictures
Here is the picture
please add - what in tSystem settings?
And i tried this version but usually the same error
1) "cmd"
2) "/c"
3) "python" 4) "C:\\Users\\Ines\\Desktop\\Python\\liredbf.py" 5) ((String)globalMap.get("tFileList_1__CURRENT_FILEPATH"))
ok, and on original post, and on picture - I saw wrong name of variable
correct -
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
on picture and in original post -
((String)globalMap.get("tFileList_1__CURRENT_FILEPATH"))
please double-check
it also my mistake, because I copy past from Your post, but this is could be reason for NullPointer error