Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Not applicable

FTP import iteration for multiple files

Hi all,

I'm completely stumped with how I would go about loading in all the .CSV files in a given FTP directory base on the date added to that directory... Any ideas?

thanks

Tags (1)
4 Replies
disqr_rm
Valued Contributor III

FTP import iteration for multiple files

You can have a ftp batch running, or a qvw in batch calling ftpxx.bat file with EXECUTE command, which will download newer files added in last hour and load them in QV. Just a quick idea.

Not applicable

FTP import iteration for multiple files

hey thanks for the reply - I'm still not sure how I would do that though?

disqr_rm
Valued Contributor III

FTP import iteration for multiple files

OK. Let me explain little details.

1. Put code below in a batch file (say GetFileDir.bat). Thanks to http://www.computing.net/answers/programming/ftp-dos-batch-file/15347.html


@echo off > %0.ftp
>> %0.ftp echo o mysite.com
>> %0.ftp echo username
>> %0.ftp echo password
>> %0.ftp echo dir
>> %0.ftp echo bye
ftp -s:%0.ftp > %0.txt


2. Now that you have a list of files in text file, you can read it and loop through them. In the loop you can determine which file you need to download - based on date, file name sequence, etc. For those file, you may call another batch file (say GetMyFile.bat). For this have a look here: http://www.ericphelps.com/batch/samples/ftp.script.txt

Not applicable

FTP import iteration for multiple files

Thanks Rakesh - I will look into that way of doing it.

In the last hour I was looking through the QlikView Reference document and came across this subroutine...

sub DoDir (Root)

for each Ext in 'qvw','qvo','qvs','qvt','qvd','csv'

for each File in filelist (Root&'\*.'&Ext)

Load

'$(File)' as Name,

FileSize('$(File)') as Size,

FileTime('$(File)') as FileTime

autogenerate 1;

next File

next Ext

for each Dir in dirlist (Root&'\*')

call DoDir (Dir)

next Dir

end sub

call DoDir ('C:\Temp')



I put a .CSV file into the C:\Temp directory and tested this but I'm not sure how to actually load the file's contents... I think this may be the right way of going about it and I'll add the FTP stuff in later, but first I want to try doing this with some test files in the C:\Temp folder...

Sorry but I'm a bit new to QV Smiley Happy