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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
tsoley9262
Contributor III
Contributor III

Loading CSV File with the newest date

I have a folder where a csv file is stored daily with same name but most current date 'pending-reboots.2020-02-04' and i want my script when it runs just to choose the current file any help would be appreciated.

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

This should work for you I believe:

 

FILES1: LOAD * INLINE [FileName];
FOR Each f IN FileList( 'pending-reboots.*.csv')
  FILES: CONCATENATE LOAD '$(f)' AS FileName AUTOGENERATE 1;
NEXT
FILES: LOAD MaxString(FileName) AS TheFile RESIDENT FILES1 GROUP BY 1;
TheFile = Peek('TheFile');
DROP TABLES FILES1, FILES;

LATEST_FILE:
LOAD
  *
FROM
  [$(TheFile)] (txt);
  
TheFile=;

 

View solution in original post

3 Replies
petter
Partner - Champion III
Partner - Champion III

This should work for you I believe:

 

FILES1: LOAD * INLINE [FileName];
FOR Each f IN FileList( 'pending-reboots.*.csv')
  FILES: CONCATENATE LOAD '$(f)' AS FileName AUTOGENERATE 1;
NEXT
FILES: LOAD MaxString(FileName) AS TheFile RESIDENT FILES1 GROUP BY 1;
TheFile = Peek('TheFile');
DROP TABLES FILES1, FILES;

LATEST_FILE:
LOAD
  *
FROM
  [$(TheFile)] (txt);
  
TheFile=;

 

tsoley9262
Contributor III
Contributor III
Author

Thank You I will give this a try!!

petter
Partner - Champion III
Partner - Champion III

Please click the like button or heck if the response was correct you could even mark it as a correct solution.
Believe me - it will be greatly appriciated by the contributors ...
We love likes as much as anyone posting anything on social media