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 Bro,
Kindly can you help on above the logic. Please share job so i can go though where i am missing.
Thanks
Shree
Hi Shree,
What questions do you currently have? I'm afraid I cannot build you a job because I do not have your data, environment and do not fully understand your full requirement. I also have a fair amount of work on at the moment. I can (and am happy to) help by answering questions about specific problems, but I will need the full details of the problem.
Regards
Richard
Hi,
Please find the below requirement and take your time and please help on this.
Source Type: Oracle
Records:
txn_date,num
12-06-2017,12
13-06-2017,24
12-06-2017,13
14-06-2017,14
13-06-2017,24
Expected Output:
1) Create folders based on unique txn_date. Above source records it will create 3 folders. (12Jun2017, 14Jun2017 and 13Jun2017)
PATH: c:/12Jun2017/filename.xlsx
Folder Format: 12Jun2017
Inside folder: create xlsx file.
Records: filename12.xlsx
txn_date,num
12-06-2017,12
12-06-2017,13
Simliar to other two folder.
PATH: c:/13Jun2017/filename13.xlsx
Folder Format: 12Jun2017
Inside folder: create .xlsx file.
Records: filename.xlsx
txn_date,num
13-06-2017,24
13-06-2017,24
PATH: c:/14Jun2017/filename14.xlsx
Folder Format: 12Jun2017
Inside folder: create .xlsx file.
Records: filename.xlsx
txn_date,num
14-06-2017,14
Thanks for your time. Let me know if you have any questions to understand requirements.
Regards
Shree
First of all, you do not need to worry about creating unique folders. Get that out of your mind. When you create a new file, if the folder does not exist, it will be created (so long as your user running the Talend Studio or Service has permissions to create folders in the base location).
For example, if you have a base folder of C:\MyBase and want to add files to unique folders based on dates (as you have described), then this is what you need to do.
I will base this on the data below....
txn_date,num
12-06-2017,12
13-06-2017,24
12-06-2017,13
14-06-2017,14
13-06-2017,24
1) First thing you need to consider, if you are going to create multiple files and folders during this job you MUST group your data by txn_date and num. You will need a subjob that will simply return the txn_date + num group key values, create your filepath from that, and iterate to another subjob containing the rest of your code.
t{DB}Input --row-->tMap---->tFlowToIterate--iterate-->t{DB}Input----rest of job--->
Look at the high level flow above. You write a query with a group by clause grouping by txn_date and num. Return txn_date and num.
In the tMap create your complete file path from your base folder to filename. Pass this and the txn_date and num columns to the tFlowToIterate.
The tFlowToIterate will automatically create globalMap variables of the data you have created. Everything after the tFlowToIterate can use those variables. Use the globalMap variables for txn_date and num in the query for the next t{DB}Input component. That will return all of the data for the txn_date and num key.
2) Now you just have to create your mapping to the output file. The output file will be connected either directly to the t{DB}Input component or via a tMap (or similar). Use the globalMap variable for your path in the file component.
What will happen in the above is that for every unique txn_date and num you will get a file created with the corresponding data. If the same txn_date is used for several dufferent num values, it doesn't matter. If the txn_date folder has been created, then it will just add a new file in that folder. If it has not been created then it will create the folder when it creates the file.
I hope this helps
Hi,
Thanks for your input,
Small query if we group by txn_date and num. will get duplicate txn_date.
Query:
SELECT txn_date,NUM FROM test_data GROUP BY txn_date,NUM
Output:
12-06-2017,12
12-06-2017,13
13-06-2017,24
14-06-2017,14
Shall i group only txn_date.
Regards
Shree
This grouping represents your file NOT your folders. Remember, you do not care about folders being unique. It is impossible to create duplicate folders and the file component is lever enough to know whether to create a folder that is not there or reuse an existing one.
Hi,
Thank you so much. Let me work on it.
Thanks
Shree