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
I'm afraid I cannot open your job since I am currently using an older version of Talend. But it is clear that you are trying to create a folder that already exists using the mkdir command. Instead of using tSystem to create directories why not use a tLogRow to print out the directories it is going to create to see how the duplication occurs.
Also note, you are trying to create a directory called "null". This happens in Java when you are concatenating Strings and one of those Strings is null.
You need to refine your data collection and data validation.
Hi,
Still i am getting same error.i have tried with tLog_row, i getting null, How to track. i am attaching screen shot for references.
tJavaRow_1:
globalMap.put("C:/outputFolder", input_row.newColumn1);
output_row.newColumn2 = input_row.newColumn2;
Any inputs would be helpful.
Thanks
Shree
You do not appear to be passing the value of input_row.newColumn1 to your output. You are setting your globalMap value (strangely to a key of "C:/outputFolder"....why?), but not passing the value to the output_row.newColumn1 column. Your tLogRow will be displaying this. We will need to see your tSystem configuration.
OK, I think I know what is going wrong. But it is difficult to tell for sure, so you will need to try this.
1) Disconnect your tJavaRow from your tUniqRow
2) Connect a tFlowToIterate to your tUniqRow
3) Use an iterate link from the tFlowToIterate to your tSystem component
4) In your tSystem component use the following code....
"cmd /c mkdir " + ((String)globalMap.get("row2.newColumn1"))
FYI the tFlowToIterate works by adding the row to the globalMap using the row name and column name as the key. Each iteration keeps those values for the whole of the flow of the iteration.
Hi ,
Thanks for suggestion.
Now, able to created directory based on unique txn_date.
Observation: if directory already exist it through error.
error msg: A subdirectory or file 07-12-0012 already exists.
2) Year is not properly value. i will check this one.
Final Requirement:
Source records:
Columns are:
txn_date, num
12-06-2017,12
13-06-2017,24
12-06-2017,22
14-06-2017,24
12-06-2017,13
13-06-2017,24
tOracleInput_1 ==> tFileOutputExcel_1
1) Create unique txn_dt directory. Ex: 12-06-2017, 13-06-2017 etc
2) Inside that directory create xlsx file. date_wise_load.xlsx ( like 12-06-2017)
3) Load that date records.
Output File:date_wise_load.xlsx
txn_date,num
12-06-2017,12
12-06-2017,24
12-06-2017,13
4) If directory already exist though error and send notification either email. Keep job running.
Thanks once again for right direction
Regards
Shree
You do not need to do this. Below is a MUCH simpler way of achieving your goal.
1) Create the folder path String as before
2) Do not use a tSystem, use a tFileTouch component to create a file (you choose the name) in the folder you want to create. Select "Create direcory if does not exist".
3) Delete the file you have just created
There is no need to keep track of what folders you have create since this method will not error if you recreate the same folder.....because you cannot do that this way.
Hi ,
Sorry, i am missing some loops now.
I have attached screen shots.
Could you please check and tell me the flow.
Thanks
Shree
At the end of your path you need to add a filename (maybe "del.me"). This will create a file inside the folder. At the moment it is assuming your folder is a file. Once the "del.me" file is there, you can delete the "del.me" file.
Not sure what you meant about loops?
Hi,
I am using below flow.
tfiledelimited_1 => tUniqueRow_1 => tFlowToIterate_1 => tFileTouch_1
tFileTouch_1:
Properties:
File: "C:/Users/DELL PC/Desktop/reports/SOURCE FILE 3/" + ((String)globalMap.get("row2.newColumn2"))
Checked: create direcotry if does't exist
I am able to create file with empty records. but folder are created.
Please let me know any changes required?
Thanks
Shree