Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Friends
I have three folders in D drive each having some text files.
I want to run load statement to load all the text files from folders.
Thanks
Hi,
Try like this
Data:
LOAD
*
FROM Folder1\*.txt;
Concatenate(Data)
LOAD
*
FROM Folder2\*.txt;
Concatenate(Data)
LOAD
*
FROM Folder3\*.txt;
Regards,
Jagan.
Thanks Jagan
But the format for all text file are same so I want to load all text files at a go from all folders.
Thanks
Try something like:
for each Dir in dirlist (Root&'\*' )
Load '$(Dir & '\*.txt')' <- not sure if this statement works
next Dir
Hi Pavan,
Then you have to loop the folders using For loop or if it is just 3 folders then you can use above script.
FOR Each Dir in dirlist (Root&' \*' )
Data:
LOAD
*
FROM $(Dir)\*.txt;
NEXT Dir
Regards,
Jagan.
You can also do it like,
Config:
Load * inline [
path,
'c:\'
'D:\'
'c:\Data\'
];
For i=0 to noofrows('Config')-1
let path=peek('path',0,'Config');
Test:
Load
......................
your fields
.....................
From
$(path)*.txt (txt, codepage is 1252, no labels, delimiter is ' ', msq);
In the config you can define all the path u want to load
Jagan I am using the code. The highlighted is my path name where all the text files are there. Can you send me the code please
Load *
FROM
[D:\test\9_30\9_30\*.txt]
Jagan
Could you please explain the code how it works.
Thanks
Config:
Load * inline [
path, Location
Path1, 'D:\test\9_30\9_30\' ,
Path2, 'D:\test\9_31\9_31\'
];
For i=0 to NoOfRows('Config')-1
let path= Peek('Location', $(i), 'Config');
Table:
Load
*
From $(path)*.txt (txt, codepage is 1252, no labels, delimiter is ' ', msq);
Next i
Drop Table Config;
Hi,
The below code loops through all the folders in the given root path using FOR EACH loop and loads all the text files in each folder, we have used wildcard characters *.txt to load only txt files.
SET Root = 'D:\test\9_30\9_30';
FOR Each Dir in dirlist (Root&' \*' )
Data:
LOAD
*
FROM $(Dir)\*.txt (txt, codepage is 1252, no labels, delimiter is ' ', msq);
NEXT Dir