Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
KarimBen
Contributor II
Contributor II

Merge data from several TXT files from subfiles

Hi Community, 

I need your help for the following Problem that I have. 

I Have to merge Several Txt Data sets from different Subfolders in to one QVD, 
and attached with the foldername.  

I try it with this Script but i get an error:

"Field names must be unique within table"

Set vConcatenate = ;

sub ScanFolder(Root)

for each FileExtension in 'txt'

for each FoundFile in filelist( Root & '\*.' & FileExtension)

FileList:

set vConcatenate;
first 10
LOAD *,

mid('$(FoundFile)' ,51,7) as Maschine,
mid('$(FoundFile)',59,11) as Material,
'$(FoundFile)' as Foundfile
FROM [$(FoundFile)] (txt, utf8, embedded labels, delimiter is '|', msq);

Set vConcatenate = Concatenate;

next FoundFile

next FileExtension

for each SubDirectory in dirlist( Root & '\*' )

call ScanFolder(SubDirectory)

next SubDirectory

end sub

Call ScanFolder('lib://QNAP BDE (prst_a.benchigra)/BDE Datenablage/') ;

 

2021-10-25 17_01_26-20211022113026.png

 

 

1 Reply
anthonyj
Creator III
Creator III

Hi @KarimBen ,

It looks like your call of vConcatenate is not quite right. Just above the "First 10" it shouldn't have "Set vConcatenate" it should just read as $(vConcatenate). I think it also has to be moved above the table name "FileList".

I hope that does the trick.

Regards

Anthony