Question

Directory name generalization

  • 11 December 2012
  • 4 replies
  • 7 views

Hi everyone,

 

 

I am pretty new with FME and I am using it to manipulate data that is delivered to my company on a quarterly basis. Because of this, there is a 'date stamp' on the folder name (for example "Current/Transport/Roads NOVEMBER 2012/Standard/") where NOVEMBER can have four different month names, depending on release date.

 

 

What I am trying to do is to 'generalise' the directory path in the readers with some wildcards if that's possible? I'd like to create a directory path that finds the files, no matter what's the date as long as the data is stored inside the 'Current' folder, for example 'Current/Transport/Roads */Standard/'

 

 

Hope I am being clear in this? Any help/suggestion would be greatly appreciated.

 

 

Thank you

 

Gianluca

4 replies

Badge +14
It completely depends on the detail but you could either use the Advanced Browser and define your input data path like:

 

 

"C:\\Folder\\Folder\\**\\*.SHP

 

 

Which would read any Shape files found in any folder below c:\\folder\\folder. If you want to be more controlled and be able to also set the top level folder as your ppst suggests you might need to build your path first. Using just one workspace consider creating a couple of published parameters and then use a combination of ParameterFetcher and StringConcatenator to build the path you want to read from and then pass that path into a Transformer like the FeatureReader. You could of course use two workspaces where the first builds the path to read the data from and sends those paths to a Workspace runner and passes the required paths into the Reader Parameters of the workspace that does the work.

 

 

A few options perhaps.
Hi Gianluca,

 

 

I guess the easiest way to read multiple files is the 'advanced browser' in FME. When you add a reader and you browse for your data, you can also click on the 'green cross' at the right. Then the advanced browser opens. Here you can say 'add directories'. In your case you could choose 'Current/Transport/Roads/' and then click the option 'subdirectories'. Then all the files from NOVEMBER, DECEMBER...as subdirectories will be read.

 

 

Hopefully that helps,

 

best regards,

 

Stefan
Badge +22
You can be a bit more specific than the default advanced browser

 

 

for your case something like 

 

Current\\Transport\\**\\Standard\\

 

 

will find every subdirectory of Transport that itself contains a directory Standard, and is recursive so will find

 

 

Current\\Transport\\1\\Standard\\

 

as well as 

 

Current\\Transport\\1\\Standard\\2\\Standard

 

 

or without recursion you can use:

 

 

Current\\Transport\\Roads*\\Standard\\

 

 

which will find every directory in Transport that starts with Roads and contains a subdirectory Standard.

 

 

depending on which reader you're using you can also do pattern matching on the file name

 

*.shp

 

road*.csv

 

 

etc.
Hello everyone,

 

 

First of all, thank you for replying!

 

 

I followed the instructions of each of you and unfortunately I was not able to overcome the issue... Maybe it's because of my inexperience!!!

 

 

When I open the advanced browser and select the directory, for example

 

 

"C:\\DATA\\Current\\SHP\\Transport\\Roads NOVEMBER 2012\\Standard"

 

 

and manually change it to

 

 

"C:\\DATA\\Current\\SHP\\Transport\\Roads*\\Standard" then I click 'OK', the program prompts me to create a new directory because it doesn't exist. Maybe I have to add an escape character so FME will understand that I am using a wildcard?

 

 

Thanks heaps!

 

 

Gianluca

Reply