Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am using below script for error handling geeting error message (Script line error).
Please help me.
Set vConcatenate = ;
sub ScanFolder(Root)
for each FileExtension in 'txt'
for each FoundFile in filelist( Root & '\Protection_*.' & FileExtension)
set ErrorMode=0;
Protection:
LOAD
ID,
Name,
Premium,
FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
Set vConcatenate = Concatenate;
if ScriptError=11 then
next FoundFile
else
for each FoundFile1 in filelist( Root & '\Protection_*.' & FileExtension)
Protection:
LOAD
ID,
Name,
Premium,
FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
Set vConcatenate = Concatenate;
next FoundFile1
endif
next FileExtension
for each SubDirectory in dirlist( Root & '\*' )
call ScanFolder(SubDirectory)
next SubDirectory
end sub
Call ScanFolder('C:\Production\Life\Data');
Regards
Ashish
Set vConcatenate = ;
Set vtest = ;
sub ScanFolder(Root)
for each FileExtension in 'qvd'
for each FoundFile in filelist('$(Root)\*.$(FileExtension)')
set ErrorMode=0;
Protection:
LOAD
ID,
Name,
Premium
FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
Let vtest = ScriptError;
Set vConcatenate = Concatenate;
if '$(vtest)'<>'Field Not Found' then
Set vConcatenate = Concatenate;
for each FoundFile1 in filelist( '$(Root)\*.$(FileExtension)')
Protection:
LOAD
ID,
Name,
Premium
FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
Set vConcatenate = Concatenate;
next FoundFile1
endif
NEXT FoundFile
next FileExtension
for each SubDirectory in dirlist('$(Root)\*' )
call ScanFolder('$(SubDirectory)')
next SubDirectory
end sub
Call ScanFolder('D:\Projets\QlikView\Concours AM-DV\5-QVD');
Hi,
The above script given me duplicate record.
Duplicate record is comming because it relode one file three time
I want it's relode one file only one time.
Regards
Ashish
Please help me urgent basic.
Hi,
i am wating for your reply it urgent for me.
I culd not find any soluation.
Please help me.
Thanks in advance.
Regards
Ashish
Hi Ashish,
you are using 2 for each loops and loading the same file from the folder, thats y the duplicate issue.
I think the below script should solve your problem.
Set vConcatenate = ;
sub ScanFolder(Root)
for each FileExtension in 'txt'
for each FoundFile in filelist( Root & '\Protection_*.' & FileExtension)
set ErrorMode=0;
Protection:
LOAD
ID,
Name,
Premium,
FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
Set vConcatenate = Concatenate;
next FoundFile
next FileExtension
for each SubDirectory in dirlist( Root & '\*' )
call ScanFolder(SubDirectory)
next SubDirectory
end sub
Call ScanFolder('C:\Production\Life\Data');
thanks,
Shruthi
Hi,
Set vConcatenate = ;
Set vtest = ;
sub ScanFolder(Root)
for each FileExtension in 'txt'
for each FoundFile in filelist('$(Root)\*.$(FileExtension)')
set ErrorMode=0;
Test:
LOAD
ID,
Name,
Premium
FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
Let vtest = ScriptError;
Set vConcatenate = Concatenate;
if '$(vtest)'<>'Field Not Found' then
Drop table Test;
Set vConcatenate = Concatenate;
for each FoundFile1 in filelist( '$(Root)\*.$(FileExtension)')
Protection:
LOAD
ID,
Name,
Premium
FROM [$(FoundFile1)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
Set vConcatenate = Concatenate;
next FoundFile1
endif
NEXT FoundFile
next FileExtension
for each SubDirectory in dirlist('$(Root)\*' )
call ScanFolder('$(SubDirectory)')
next SubDirectory
end sub
And now?
Regards,
Aurélien
Add "EXIT For" at the end (between endif & NEXT FoundFile)
Hi,
purposely i am using two loop.
Loop1 will be excute upto script error(Filed not found).
Loop2 will be excute for no error.
Regards
Ashish
Hi,
It again given me duplicate value and load one file three time.
Regards
Ashish