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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
rittermd
Master
Master

Load only latest file?

I will receive a new pipe delimited text file with the previous days transaction each day.   I want to update an existing QVD with just the data in the latest file.  The file name does include a date/time stamp.

Not sure how to go about this?

2 Replies
Vegar
MVP
MVP

Try this:
set vRoot = 'C:\myfolder';

FOR Each File in filelist ('$(vRoot)'&'\*.txt')
Files:
Load
'$(File)' as Name,
FileTime( '$(File)' ) as FileTime
autogenerate 1;
next File

Right join (Files)
Load
Max(FileTime) as FileTime
Resident Files;

//populate a variable with the latest file
Let vLatestFile = peek('Name',-1,'Files');

In the example I use the file time, but you could of course try to cut out the timestamp from the file name and use that value the right join aggregation.

jim_chan
Specialist
Specialist

hi there , i have followed your srcipt. and i can spot the latest file. for example - this is my latest file data_201912.txt, now , continuing from your script, how to i load the txt file and store it as data_201912.qvd???