Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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=;
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=;
Thank You I will give this a try!!
| 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 |