Skip to main content
Solved

Open multiple datasets in multiple folders on FTP server directly ?

  • May 3, 2018
  • 3 replies
  • 27 views

lifalin2016
Supporter
Forum|alt.badge.img+38

Hi,

As far as I can see, it's not possible to open a FTP based dataset directly in a reader (MapInfo TAB) ?

And FTPCaller only allows a single file to be downloaded at any time ?

I have multiple folders with multiple datasets (consisting of multiple files) to import, and doesn't want to do this one file at a time.

The optimal solution would be to open the datasets with a wildcard directly in a reader. Just like how you can within a ZIP.

How to proceed ?

Cheers.

Best answer by danilo_fme

Hi @lifalin2016,

I believe this post can to help you Use PythonCller to get list of files in Directory

Thanks,

Danilo

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.

3 replies

danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • Best Answer
  • May 6, 2018

Hi @lifalin2016,

I believe this post can to help you Use PythonCller to get list of files in Directory

Thanks,

Danilo


lifalin2016
Supporter
Forum|alt.badge.img+38
  • Author
  • Supporter
  • September 27, 2018

Hi @lifalin2016,

I believe this post can to help you Use PythonCller to get list of files in Directory

Thanks,

Danilo

Thanks danilo_fme.

 

 

I originally fetched the data manually, and read them from my HDD instead.

 

 

However, I just revisited all my unanswered question, and decided to test the FTP Python code.

 

 

It took awhile to get it to work, though, but it does now.

 

 

Unfortunately one still needs to download multiple files to get a single dataset for FME to read (ESRI Shape, MapInfo TAB etc.), but at least it's now automateable.

 

 

Cheers.

 


lifalin2016
Supporter
Forum|alt.badge.img+38
  • Author
  • Supporter
  • September 27, 2018

Hi @lifalin2016,

I believe this post can to help you Use PythonCller to get list of files in Directory

Thanks,

Danilo

Here's the Python code in case someone else wants to tinker:

 

import fme
import fmeobjects
import ftplib

class FeatureProcessor(object):
    def __init__(self):
        pass

    def input(self,feature):
        pass
        CSVlist = []
        _ftp = ftplib.FTP("ftp.safe.com")
        _ftp.login() #anonymously
        _ftp.cwd("fmebuilds")
        try:
            CSVlist = _ftp.nlst()
        except ftplib.error_perm, resp:
            if str(resp) == "550 No files found":
                print("No files found")
            else:
                pass
                #raise
        _ftp.quit()
        pass
        for i,v in enumerate(CSVlist):
            _var = "_list_CSVs{{{}}}".format(i)
            feature.setAttribute(_var, v)
        self.pyoutput(feature)
        
    def close(self):
        pass