Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
k526
Contributor
Contributor

how to load multiplefiles into multiple tables and the have to load only the latest filedate only

Hi,

I have to load 5 files with  filenames example as indi_20101010052121.csv,

                                                                            can_20101010052121.csv,

like wise .i have created a job ltfileinputdelimted--->tmap--->tmysqloutput

 

can u please suggest how to load only the latest files .

 

Thank you

 

 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi,

Please follow the below steps, this might help.

1. tfilelist component and set the parameter Order by and Order action in such a way that latest file comes last.  

2. Take a iterate Link from tfilelist to tjava component.

3. Create context variable for the file name. Inside tjava set the context variable to the talend varibale ((String)globalMap.get("tFileList_1_CURRENT_FILE"));

4. Take out a Onsubjob ok from tfilelist to your existing tfileinputdelimited. use the context name for the file name.

 

Cheers!

Gatha

 

View solution in original post

15 Replies
Anonymous
Not applicable

It looks like your files contain a timestamp (yyyyMMddHHmmss). As such, you can order the files (tSortRow) by the filename (assuming that the file prefix indicates a different type and you want to retrieve the latest for each type). If you want to filter the files to 1 file (the latest) per type, use a tAggregateRow component, group by type (you will need to extract that using Java String utils) and return the First function for all of the columns (assuming you have sorted the data by type and date.

k526
Contributor
Contributor
Author

tsortrow we can use for columns .but i need based upon the filename date the inputfiledelimeted has to load latest file to the database
Anonymous
Not applicable

Hi,

Please follow the below steps, this might help.

1. tfilelist component and set the parameter Order by and Order action in such a way that latest file comes last.  

2. Take a iterate Link from tfilelist to tjava component.

3. Create context variable for the file name. Inside tjava set the context variable to the talend varibale ((String)globalMap.get("tFileList_1_CURRENT_FILE"));

4. Take out a Onsubjob ok from tfilelist to your existing tfileinputdelimited. use the context name for the file name.

 

Cheers!

Gatha

 

k526
Contributor
Contributor
Author

I dont have idea

3.Create context variable for the file name. Inside tjava set the context variable to the talend variable ((String)globalMap.get("tFileList_1_CURRENT_FILE"));
4. Take out a Onsubjob ok from tfilelist to your existing tfileinputdelimited. use the context name for the file name.

can you please help me in this?
Anonymous
Not applicable

here are the screenshots on how you can do

0683p000009Luyr.jpg

 

under tfileinputdelimited component, pls configure like below Instead F:/Gatha -pls use your file path.

0683p000009Lv3S.jpg

 

In tjava component configure as below

 

0683p000009LuV8.jpg

Anonymous
Not applicable

Did you actually test this before accepting it @k526? Given your description, it won't work. This will ONLY run the latest file (singular). Given your example files....

indi_20101010052121.csv

can_20101010052121.csv

 

.....only one file would be loaded, yet according to the timestamp they should potentially both be loaded. I assume that the time in the filename is what you want to sort by and not the actual date of the file. 

 

The solution I suggested assumed an understanding that you would have to use the tFileList and plug it into a tIterateToFlow. This would then allow you to follow the rest of what I suggested.

k526
Contributor
Contributor
Author

thanks for ur suggestion.I have tried what u suggested it was working .and i have found one problem that all the 5 files are loaded into a single table like wise 5 files are loaded 5 times in every table.I need solution like for

 

EX:Can file has to load only in can table,

ind file has to load only in ind table.

 

 

Anonymous
Not applicable

HI,

 

Can you please post a screenshot of your present program?

k526
Contributor
Contributor
Author

0683p000009Lv4j.png