Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
marcorizzo
Contributor III
Contributor III

script to read a lot a txt file

Hi I've got this question.

I need to read data from 100 files that are all in the same directory c:\user\data and all files are named abc1,abc2, ..., abc100.

The script for the first one is this:

LOAD @1:11 ,

     @12:43 

    

FROM

C:\Users\Marco\Desktop\Lic1.txt

(fix, codepage is 1252);

How can I write a script to read all the files ?

Thanks

Marco

3 Replies
sunny_talwar

You can do this:

LOAD @1:11 ,

    @12:43

   

FROM

C:\Users\Marco\Desktop\Lic*.txt

(fix, codepage is 1252);

assuming your file names as Lic1, Lic2, Lic3, Lic4.....

or you can loop using the approach mentioned here:

Loop through Folders and sub folders to get file names

florentina_doga
Partner - Creator III
Partner - Creator III

use for each

florentina_doga
Partner - Creator III
Partner - Creator III

use this

final:

load * inline [a

];

set errormode=0;

   

for each vFile in filelist('$(vDataFolder)*.txt')                ////////////// file

    aaa:

    LOAD

       *

FROM [$(vFile)];

     Concatenate (final:)

    LOAD

        *,

        subfield('$(vFile)','\',-1) as File_Name

    resident aaa ;

    drop table aaa;

next;

set errormode=1;