Skip to main content
Hi,

 

 

is it possible to connect to shape layers on an FTP site with a wild card?

 

 

for example this WILL WORK:

 

 

ftp://user:password@the.server.com/download/my_private_dataset.zip

 

 

But I would like to get this (or the same idea) to work:

 

 

ftp://user:password@the.server.com/download/*private*.zip

 

 

so the idea is that the reader would simply read all the layers which match the criteria.

 

 

Thanks for any suggestions!
Hi,

 

 

I don't think there is an easy way.

 

A possible workaround I can think of is to define a scripted parameter that creates a concatenated FTP path strings matched with the pattern, and link the source dataset parameter of the SHAPE reader  to that.

 

-----

 

# Scripted (Python) Parameter Example

 

# Not tested enough.

 

import ftplib, re

 

 

host = 'the.server.com'

 

user = 'username'

 

pswd = 'password'

 

 

dir = 'download'

 

base = 'private'

 

ptrn = '^%s/.*%s.*\\.zip$' % (dir, base)

 

 

prefix = 'ftp://%s:%s@%s/' % (user, pswd, host)

 

 

ftp = ftplib.FTP(host, user, pswd)

 

paths = s'"%s%s"' % (prefix, path) for path in ftp.nlst(dir) if re.match(ptrn, path)]

 

ftp.quit()

 

 

return '"%s"' % ' '.join(paths)

 

-----

 

 

Takashi

Reply