Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
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

4 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

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
Author

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

disqr_rm
Partner - Specialist III
Partner - Specialist III

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
Author

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 🙂