Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi team,
I have source oracle table and there is one column called txn_date.
values are:
txn_date
02-06-2017
04-06-2017
07-06-2017
04-06-2017
Requirement: How to create folder based on date for examples:
folder 1: c;/Txn_dt_02-06-2017/
folder 2 :c:/Txn_dt_04-06-2017/
folder 3 :c:/Txn_dt_07-06-2017/
But no duplicate folder even if same records with same date arrive.
and is possible to store single context variable to store unique txn_dt values?
Thanks
Shree
Hi,
You can set a context variable value dynamically at runtime (context.yourVariable = "whatYouWant") but usaully for this king of usecase it's preferable to set a global variable.
Your design process should look like:
tOracleInput -> tUniqRow (eliminates doublons on date values) -> tJavaRow (here set the desired global variable) -> tSystem (to create directory)
To set the global variable, use the following:
globalMap.put("outputFolder", inuput_row.txn_date);
As there is not dedicated somponent to create an empty folder, use tSystem for this purpose with the following command:
"cmd /c mkdir " + ((String)globalMap.get("outputFolder"))
Hope this helps.
I see where @shong is going with the above. If you are intending to add data to the folder, there is no need to worry about this problem.
1) You cannot create a folder twice. Once it exists, it exists
2) When you want to write a file to a folder in Talend, you can set the file to create the folder if it does not already exist
Unless there is some other requirement here, you really do not need to worry about this.
Hi Shong.
Sound good, if we can store records as well based on dates. ex: 4th day records-> create folder(04-06-2017)/txn_dt_4th_data.csv. similar to other days as well.
Means time need to store the date values in context variable in single or mutiple context variable.
After that, i am going to use this context variable for some excel file creation based on some columns like gender='M' etc.
Thanks
Shree
Hi,
As per suggestion whether it will create distinct folder based on date unique values?
Thanks in advance.
Regards
Shree
Hi,
I have tried as your input.
I have facing error while creating folder using tSystem component. I have attached screen shot for references.
One more point rather than using tUniquerow , we can override distinct in tOracleInput itself?
Error message:
A subdirectory or file null already exists.
Thanks
Shree
Hi,
Still i am facing same error.
I am attaching job for your reference. Could you please check it.
Thanks
Shree