Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
rp2018
Creator
Creator

How to get the latest file from a directory?

I have following 4 files as an example in c:\temp directory and would like to get the latest file to load to the sql server database.

How to design a job to get the latest file?

File format: filename_yyyyMMdd_HHmmss.csv

Test_20230201_092511.csv

Test_20230201_093025.csv

Test_20230201_095010.csv

Test_20230201_095515.csv

Labels (3)
1 Reply
Anonymous
Not applicable

Hello @Ranjan Patel​ ,

Maybe you can design the job like :

  1. use tFileList to list all the csv files in the folder and sort by filename 'DESC' as the below

0695b00000cgnSeAAI.png 2 add the tJava to get the top 1 file path and setup context variable "latest_file_path" to save it as the below

0695b00000cgnTSAAY.png 3 add tFileInputDelimited to read the file path context.latest_file_path and send the content to sqlserver db by tDBOutput as the below

0695b00000cgnUBAAY.png