Skip to main content
Solved

How can i use wildcard in reader, when reading from a FTP server


I will like to automate my weekly ftp download.

Mapinfo reader example url (as zip with multiple mapinfo files):

ftp:// ftp.data.com/Geodata_202103159999 .zip

 

'Geodata_' is always there,

'20210315' is the data that changes (every monday when data is downloaded)

'9999.zip' is always there

 

In my logik the easiest would be ftp://ftp.data.com/Geodata_*.zip

But it doesnt work. 'Geodata_' must be there can be multiple zip files on the server.

 

Any suggestions on this problem?

Best answer by chrisatsafe

When it comes to reading from an ftp, you need to specify the complete url so wildcards will not work. However, there are ways to work around this. I tend to do this by getting a list of the filenames from the FTP then feeding the url into the Feature Reader (see attached). You can build the wildcard logic into the Tester before the FeatureReader so that only the files you are interested are read into the workspace.

2021-03-17_11-54-50This example, uses a generic port on the feature reader so I've specified the attribute I wanted to have exposed in the FeatureReader's Attribute & Geometry Handling > Generic Port > Attributes to Expose parameter.

 

Others have been successful with the approach listed on this post as well.

View original
Did this help you find an answer to your question?

10 replies

chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • Best Answer
  • March 17, 2021

When it comes to reading from an ftp, you need to specify the complete url so wildcards will not work. However, there are ways to work around this. I tend to do this by getting a list of the filenames from the FTP then feeding the url into the Feature Reader (see attached). You can build the wildcard logic into the Tester before the FeatureReader so that only the files you are interested are read into the workspace.

2021-03-17_11-54-50This example, uses a generic port on the feature reader so I've specified the attribute I wanted to have exposed in the FeatureReader's Attribute & Geometry Handling > Generic Port > Attributes to Expose parameter.

 

Others have been successful with the approach listed on this post as well.


  • Author
  • March 19, 2021

Perfect, that works! Thanks!


Forum|alt.badge.img+1
  • February 18, 2022

@chrisatsafe​ ​ But what if the first point of entry on your ftp is just a folder, that changes name every week, and you need to read a specific zip file within that folder? Basically I need to go one step deeper to read my zipped shapefile.

So do I do the list trick once more and can I do that from the first Tester?

I'm also not completely sure I understand what the @GetWord value does?image


chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • February 18, 2022
larsec wrote:

@chrisatsafe​ ​ But what if the first point of entry on your ftp is just a folder, that changes name every week, and you need to read a specific zip file within that folder? Basically I need to go one step deeper to read my zipped shapefile.

So do I do the list trick once more and can I do that from the first Tester?

I'm also not completely sure I understand what the @GetWord value does?image

Yes exactly. The example in that workspace is just going for a file but if you need to list the folder and then list the files for that folder you can essentially do the same logic twice. If you set the first FTPCaller to ftp://ftp2.census.gov/acs2002/ you'll be provided with a list of everything in that directory which you can then filter for in the Tester (for example URL = Core_Tables).

Then In the second FTPCaller, you can then set the URL to ftp://ftp2.census.gov/acs2002/@Value(URL)/ and it will return the list of files in that directoryimage


chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • February 18, 2022
chrisatsafe wrote:

Yes exactly. The example in that workspace is just going for a file but if you need to list the folder and then list the files for that folder you can essentially do the same logic twice. If you set the first FTPCaller to ftp://ftp2.census.gov/acs2002/ you'll be provided with a list of everything in that directory which you can then filter for in the Tester (for example URL = Core_Tables).

Then In the second FTPCaller, you can then set the URL to ftp://ftp2.census.gov/acs2002/@Value(URL)/ and it will return the list of files in that directoryimage

With regards to the GetWord function:

"GetWord(string,index)

Returns the indexth word in string . If indexis a negative integer, GetWord() returns the indexth word from the end of string. If there is no word at index, an empty string is returned. Words in string must be delineated by blank spaces (space, tab, return carriage, and others)."

 

The reason it is invalid in your case is because the attribute is now called URL so it needs to be @GetWord(@Value(URL),-1) rather than @Value(_list)

image


Forum|alt.badge.img+1
  • February 28, 2022
chrisatsafe wrote:

Yes exactly. The example in that workspace is just going for a file but if you need to list the folder and then list the files for that folder you can essentially do the same logic twice. If you set the first FTPCaller to ftp://ftp2.census.gov/acs2002/ you'll be provided with a list of everything in that directory which you can then filter for in the Tester (for example URL = Core_Tables).

Then In the second FTPCaller, you can then set the URL to ftp://ftp2.census.gov/acs2002/@Value(URL)/ and it will return the list of files in that directoryimage

Thank you so much Chris, this solves a huge problem for me :-)


chrisatsafe wrote:

When it comes to reading from an ftp, you need to specify the complete url so wildcards will not work. However, there are ways to work around this. I tend to do this by getting a list of the filenames from the FTP then feeding the url into the Feature Reader (see attached). You can build the wildcard logic into the Tester before the FeatureReader so that only the files you are interested are read into the workspace.

2021-03-17_11-54-50This example, uses a generic port on the feature reader so I've specified the attribute I wanted to have exposed in the FeatureReader's Attribute & Geometry Handling > Generic Port > Attributes to Expose parameter.

 

Others have been successful with the approach listed on this post as well.

HI Chris, Is there a difference between doing this in FME workbench vs. setting this up in FME Server?

 

I got this running smooth on my local workbench, but it is timing-out when I run it on the Server. I am getting this error:

"FTP/FTPS/SFTP transfer error: Timeout was reached"

"Termination Message: 'FTPCaller output a <Rejected> feature."


chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • August 31, 2022
ohyacinthe wrote:

HI Chris, Is there a difference between doing this in FME workbench vs. setting this up in FME Server?

 

I got this running smooth on my local workbench, but it is timing-out when I run it on the Server. I am getting this error:

"FTP/FTPS/SFTP transfer error: Timeout was reached"

"Termination Message: 'FTPCaller output a <Rejected> feature."

Hi @ohyacinthe​ ,

Hmm, it should be the same. Do you have workbench installed locally on the server machine? Could you try from there?

 

Only thing that comes to mind for me would be any network related differences preventing the connection (proxy, firewall, other).


ohyacinthe wrote:

HI Chris, Is there a difference between doing this in FME workbench vs. setting this up in FME Server?

 

I got this running smooth on my local workbench, but it is timing-out when I run it on the Server. I am getting this error:

"FTP/FTPS/SFTP transfer error: Timeout was reached"

"Termination Message: 'FTPCaller output a <Rejected> feature."

Thanks Chris!

Unfortunately y workbench is definitely NOT installed on my server machine. From previous versions of my team’s FME Server, I remember that developing workflows from the server machine’s workbench makes publishing workspaces to the server a lot easier.

1. I’ll look to configure known office proxy settings in my local workspace and try it again on the server.

2. I’m going to ask my team if there is a workbench instance installed on our FME server and start from scratch if I’m still stuck.

Thanks,

Keye


plm
  • December 21, 2022
chrisatsafe wrote:

When it comes to reading from an ftp, you need to specify the complete url so wildcards will not work. However, there are ways to work around this. I tend to do this by getting a list of the filenames from the FTP then feeding the url into the Feature Reader (see attached). You can build the wildcard logic into the Tester before the FeatureReader so that only the files you are interested are read into the workspace.

2021-03-17_11-54-50This example, uses a generic port on the feature reader so I've specified the attribute I wanted to have exposed in the FeatureReader's Attribute & Geometry Handling > Generic Port > Attributes to Expose parameter.

 

Others have been successful with the approach listed on this post as well.

Hi Chris. Hi everyone.

Thanks for the workbench. I have a similar issue. On the ftp, 2 directories. One for the exchange, another for the results.

Url are something like : ftp://.../ftpprivate/user/echange and ftp://.../ftpprivate/user/resultat

How may I list files from the both directories ? How may I connect the ftpcaller dfirectly to echange ? I got a bunch of error when I indicate ftp://.../ftpprivate/user/echange in the url of the ftp caller.

 

Thanks in advance.

 


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