Skip to main content
Solved

Read files based on list of file names

  • December 4, 2014
  • 9 replies
  • 365 views

Forum|alt.badge.img+1
Hi, 

 

 

I have a list of filenames that are located within a specific directory.  The list of filenames is generated within the FME workbench.  What is the best way to get the Reader to read in only the files within the larger directory?  Note: the files that I want to read in are within a number of sub-directories, which I don't know what they are. I only know the root directory.

 

 

Thanks,

Best answer by david_r

Hi,

 

 

use the Text File reader, followed by the FeatureReader (http://docs.safe.com/fme/html/FME_Transformers/Default.htm#Transformers/featurereader.htm) transformer.

 

 

David
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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.

9 replies

david_r
Evangelist
  • Best Answer
  • December 4, 2014
Hi,

 

 

use the Text File reader, followed by the FeatureReader (http://docs.safe.com/fme/html/FME_Transformers/Default.htm#Transformers/featurereader.htm) transformer.

 

 

David

fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • December 4, 2014
or using the advanced brouwser, with the subdirectories option on.....

 

or using the Directory and File Pathnames + FeatureReader......

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 4, 2014
As the filenamelist is generated within a workbench you could use a workbenchcaller to call a "readerworkbench" to add a Reader for the format you wish to read set to the rootdirectory and read subdirectories. 

 

The reader workbench must be set up with dynamic schema and when finished clear the reader content so it says "not set". Then it is a workspacecaller only bench.

 

This way you can pick items from a directory without knowing beforehand if it's their at all. (unlike the featurereader)

 

 

Because i don't see option to use attributes or parameterselection for items in a directory (not without having to go trough the motion manualy first at least)

Forum|alt.badge.img+1
  • Author
  • December 4, 2014
I've found the "Directory and File Pathnames" reader, but as my list is not an external data source, but a list that I have generated within the workbench itself, how do I get it into the reader?

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 4, 2014
..hhmm..is see i did make a workspacerunner calling a reader with a featurereader in it.

 

I paramatrised the dataset attribute so you could indeed enter a list separated by ";".

 

You could build this list using a concatenator.

 

 

The parameters for this reader are set in the navigator panel.

 

 

I use a bogus creator as a initiator.

 

 

"FeatureReader reader":

 

 

 

and the workspacecaller to call it:

 

 

 

though format is empty it will be filled at calltime.

 

 

Forum|alt.badge.img+1
  • Author
  • December 4, 2014
Thanks Gio, if possible I would like to do this without using a Workspace Runner.  Could anyone elaborate on how using the TextFile Reader + FeatureReader Transformer, or Directory and Filepath Reader + FeatureReader Transformer methods?

 

 

Where/how do I input the filenames in the text file so that only those listed are output from the FeatureReader?

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 5, 2014
As you generated the filenames in the reader you don't need to use a textfilereader or pathreader..

 

 

As i understood it, and it is explained in

 

http://blog.safe.com/2011/05/fmeevangelist78/

 

 

You coudl just attach a FeatureReader .

 

 Select the root directory and enter a File/Filter like "*.txt" (or whatever type you need).

 

Select "query the feature specified in the attribute below" and select the attribute  with the filenames (multiple filenames need to be conctenated with a colon ":" )

 

 

However when i enter a single filename like "F1.txt" or "H:\\F1.txt" (wich i copied from the directory to read it from) it does  not read the file.....

 

I also tried concatenated filenames...no dice.

 

Either im doing something wrong or it does'nt work.

 

 

 

seems somethings are repaired in fme2015(?)

Forum|alt.badge.img+1
  • Author
  • December 5, 2014
Thanks Gio, I tried concatenating with a colon ":" but I also could not get it to work.  Should the attribute simply contain:  "filenameA:filenameB:filenameC"?

 

 

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 8, 2014
Hi,

 

 

I tried different variants, but can't get it to work either. It does not even find a file when i have the featurereader read all the files....

 

 

 

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