Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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:
use for each
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;