Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I need to load the csv file from the specific directory into a table.
Can anyone tell me how to do it.
For each csvFile in filelist ('$(vDirPath)*.csv')
<TableName>:
LOAD
From $(csvfile)
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
next csvfile
I am getting on error that the from filename is missing.
Thanks
Ramesh
You can try with something like this:
vPath = File directory where you're storing xls files
For each File in FileList('$(vPath)\File*.xlsx')
TableName:
Load
Field1,
Field2,
FieldN
From $(File);
NEXT
You can just use this simple version.
load * from dirpath\*.csv (txt, codepage is 1252, embedded labels, delimiter is ',', msq);
Thanks Paul
I was doing this initially. But i would like to store it into a table and also i get a file on monthly basis so i decided to put into the for loop to concatenate the data into table. Is there anyway i scan through the files in the directory and load the same into the table.
Ramesh
of course, infact the syntax should be right.
maybe a copy / paste error, but the from variable is not the same as the for each. it has to be exactly the same upper an lower case.
you can use the csvfile variable in the load
try the debug mode
You can try with something like this:
vPath = File directory where you're storing xls files
For each File in FileList('$(vPath)\File*.xlsx')
TableName:
Load
Field1,
Field2,
FieldN
From $(File);
NEXT
In principle you are doing the right thing. Two things though:
Further, I agree with Paul that you should use the debugger to find the error. Press "Step" until you come to the relevant statements, and check that the For-Next and the Load have correct parameters.
HIC
Thanks Jamie
It worked.
Dear Henric Sir,
i want to apply same mechanism From FTP Server. i have been struggle past 10 days
I haven't tried it, but I doubt that this is possible using the FileList() function.
You could perhaps try to execute a ls command, pipe this into a local file, and read this file with QlikView. But, sorry to say, I am not an expert on ftp, so I could be wrong here...
HIC
I have actually been trying the same thing a couple of hours and by combining the mentioned solution in this post with a solution from another i came up with a nice solution. You can probably just copy/paste if you want to try it. My solution fetches all the xml files in a folder so you can just change "*.xml" to your preferred file ending.
vPath = [ftp://your_username:your_password@your_serveraddress/folder_where_the_files_are_stored]
Directory;
FOR Each File in filelist ('$(vPath)*.xml')
LOAD
Fieldname1,
Fieldname2
FROM
'$(File)'
(XmlSimple, Table is [Database/Data]);
NEXT File;