Skip to main content
Question

Connect shp reader to a file on ftp with *wildcard ?

  • August 27, 2014
  • 1 reply
  • 10 views

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!
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

takashi
Celebrity
  • August 27, 2014
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"' % (prefix, path) for path in ftp.nlst(dir) if re.match(ptrn, path)]

 

ftp.quit()

 

 

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

 

-----

 

 

Takashi

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings