Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have a script that reads files from a directory, like:
c:\data\charges\*.txt
This folder may or may not have data in it, and I don't know exactly whether the files are having or not.
Now if there is a text files in that folder then i need to have a VData = 1 or
if there is no text files in that folder then i need to have a VData = 0.
Can anyone find this solution ?
Thanks in advance.
Regards
venkat
Ah, yes, of course.
I think you already found the other thread, so why not use as suggested:
Set NoOfFiles = 0;
For each file in filelist ('C:\data\charges\*.txt');
Let NoOfFiles = NoOfFiles + 1; //This will return he n° of files
next
and then
set VData if NoOfFiles >0
??
You could use something like a temporary table
tmpTable:
LOAD FileName() as FileName
FROM
and then count the records.
Edit:
This could look like
if(NoOfRows('tmpTable') >0) then
Let VData=1;
else
let VData=0;
end if
edited by swuehl
Hi swuehl,
Thanks for your reply,
What i am trying to do is,
In a particular if Text Files are present then i need to set a variable VData = 1 or
if no Text Files are present then i need to set a variable VData = 0.
I hope so you understand what i am trying ?
Thanks in advance
Regards
Venkat
Yes, I think I understood.
I am trying to build a temporary table with an entry for each text file.
Then (please note my edit above), I check if the count of rows are >0 and set the variable accordingly.
Oh, I probably should
drop table tmpTable;
afterwards.
I think it should work, without trying it.
Regards,
Stefan
Hi ,
If no text files in that folder, then it is creating an error When Loading the script.
It should not generate an error when loading if no text files in a folder.
Regards
venkat
Ah, yes, of course.
I think you already found the other thread, so why not use as suggested:
Set NoOfFiles = 0;
For each file in filelist ('C:\data\charges\*.txt');
Let NoOfFiles = NoOfFiles + 1; //This will return he n° of files
next
and then
set VData if NoOfFiles >0
??
Hi Swuehl,
Thanks it working fine. The code is really simple and good.
Thanks once again.
Regarads
Venkat