Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear All,
I made incremental module, It's working fine for those files where I'm using static file name.
Now new requirement is that, I would like to load last created file in a folder.
For example:
First time, I loaded data from data source "SaleData-Mar01.csv".
Next time to onward, just I have to paste a file in a data source folder such as "SaleData-Mar02.csv", and load script should automatically consider it where from data should be load.
Days after days, data source files will be increased, means:
First day folder consist on: "SaleData-Mar01.csv"
Second day folder consist on: "SaleData-Mar02.csv"
Third day folder consist on: "SaleData-Mar03.csv"
and so on...
Please note, file name can be different for new day.
Kind regards,
Ishfaque Ahmed
Hi engishfaque,
You can find very helpful script in QV help. I think this is exactly what you need. Based on this script you can easy identify last created file by name or by timestamp. See operator for each..next.
FOR Each File in filelist (Root&' \*.' &Ext)
LOAD
'$(File)' as Name,
FileSize( '$(File)' ) as Size,
FileTime( '$(File)' ) as FileTime
autogenerate 1;
NEXT File
Dear All,
Any one can share me best solution for loading last data source file?
Kind regards,
Ishfaque Ahmed
Taras already did.
You only need to add code to lift the most recent file from the newly created table, like in:
// Taras' FOR-EACH solution comes here. Call the table [RawFileNames]
OrderedFileNames:
LOAD Name, FileTime
RESIDENT RawFileNames
ORDER BY FileTime DESC;
DROP Table RawFileNames;
LET vNewestFilePath = peek('Name', 0, 'OrderedFileNames')
DROP Table OrderedFileNames;
// Variable vNewestFilePath now contains the name of the most recent file
// in folder 'Root' with extension 'Ext'
Best,
Peter