I am attempting to create an automatic load which will count the number of files in a folder and then read in each of those files using a FOR/NEXT loop, and sequential filenames (eg. MyFile_1, MyFile_2, etc...).
There is one section of the code that does appear to work. The count of the filenames returns the correct value for "n", however the line of code struck out below in which I attempt to set a macro equal to the value of the field "n" will not work (this is needed so that I can end my loop at $(N) which would equal the final "MyFile_x").
If anyone can provide any insight on how I can accomplish that goal it would be greatly appreciated.
Filename() as filename
load count(DISTINCT(filename)) as n
FOR a = 2 to $(N);
Let FileName = [\\PATH\datafiles\MyFile_$(a).csv]'; // FileName is a variable representing the csv file name aka MyFile_1
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);