Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

store the dynamic values in context variable

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

 

Labels (1)
46 Replies
Anonymous
Not applicable
Author

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.

Anonymous
Not applicable
Author

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

 

 


error11.PNG
Anonymous
Not applicable
Author

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.

Anonymous
Not applicable
Author

Hi,

 

Please find the attached screen shot.

 

Easy to trace where i am doing wrong.

 

Thanks

Shree

 


2.PNG
1.PNG
Anonymous
Not applicable
Author

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.

Anonymous
Not applicable
Author

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

 

 

 

 

Anonymous
Not applicable
Author

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.

Anonymous
Not applicable
Author

Hi ,

 

Sorry, i am missing some loops now. 

 

I have attached screen shots. 

 

Could you please check and tell me the flow.

 

Thanks

Shree


Folder creation_2.PNG
Folder creation_1.PNG
Anonymous
Not applicable
Author

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?

Anonymous
Not applicable
Author

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