Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have an automatically generated files with changing names let’s say: file_name_123756, file_name_544451, file_name_654865 and so on. I would like to load only the latest file (today's file). The load looks like that :
Directory;
LOAD Company,
Ledger,
[Doc Id],
[Doc Number],
[Doc Date],
[Due Date],
[Line Debt],
[Total Exc Unallocated Cash],
[<90days],
[>90days],
[Not Yet Due],
[0-30],
[31-60],
[61-90],
[91-120],
[121-150],
[151-180],
[181-365],
[365+]
FROM
(
Have you got any suggestions how to do it?
FileName:
LOAD
SubField(SubField(FileName(),'_',3),'.',1) as NumberPortion
FROM
(ooxml, embedded labels, table is Sheet1);
Temp:
Load Max(NumberPortion) as MaxNum Resident FileName;
Drop Table FileName;
Let vMaxNum = Num(Peek('MaxNum',0,'Temp'));
Table:
Load
*
From
(ooxml, embedded labels, table is Sheet1);
FileName:
LOAD
SubField(SubField(FileName(),'_',3),'.',1) as NumberPortion
FROM
(ooxml, embedded labels, table is Sheet1);
Temp:
Load Max(NumberPortion) as MaxNum Resident FileName;
Drop Table FileName;
Let vMaxNum = Num(Peek('MaxNum',0,'Temp'));
Table:
Load
*
From
(ooxml, embedded labels, table is Sheet1);
Based on the file date you can achive the same:
for each file in filelist('C:\Lokale bestanden\Kilometers\*.xls')
KM_bestanden:
load '$(file)' as Bestand,
FileTime('$(file)') as Bestand_tijd
AutoGenerate (1);
next
let latest_file = peek('Bestand',-1 , 'KM_bestanden');
KM_laatste:
NoConcatenate
load *
Resident KM_bestanden
where Bestand = '$(latest_file )';
drop table KM_bestanden;
Create Batch File last.bat:
echo @off
for /f "tokens=1* delims=:" %%a in ('dir *.xls/o:-d/b ^| findstr /n .') do if %%a leq 1 echo LET LAST=%%b>last.qvs
on Edit Scritpt:
EXECUTE cmd.exe /C last.bat
$(must_include=last.qvs);
Use var LAST created
Hi,
Please try:
TEMP:
LOAD Distinct FilePath() AS FileName,
FileTime() AS FileTimeStamp
From
TempTable:
load *
resident TEMP
order by FileTimeStamp desc;
let vLatestFile = peek('FileName',0,'TempTable');
LOAD *
From '$(vLatestFile)'
(ooxml, embedded labels, table is Sheet1);
Regards
Neetha
Thank you for that Manish it worked well!
My only concern is that I have a lot of files in the folder and it takes a lot of time to reload.
Is there any way to reload it quicker??