Skip to main content
Solved

Pass attribute value to FeatureReader

  • October 16, 2018
  • 3 replies
  • 166 views

sunsilk11
Contributor
Forum|alt.badge.img+6

Hi I have used Directory and File Pathnames to get the latest file name from a directory containing a list csv files.

I then try to pass the fme attribute path_windows to a FeatureReader to read the csv file (see attached).

However this is not working. When I click on Preview, I expect to get a preview of the csv data. Also, it doesn't output the data from FeatureReader when I run it.

Any ideas

Best answer by david_r

A few things to look out for

  • If the filename is dynamic you need to configure the FeatureReader to use the <Generic> output port.
  • When using the <Generic> output port, do not specify "Feature types to read" as that will filter out any filenames that don't match that value.
  • When using the <Generic> output port, you'll have to manually expose the attributes returned by the CSV, such as "Lat", "Lon" etc.
  • The CSV parameters needs to be configured for Automatic attribute definition.

Example: processlatestcsvinlist.fmwt

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

3 replies

david_r
Celebrity
  • October 16, 2018

You cannot preview the file contents since FME cannot know the value of "path_windows" until the workspace is running. And when the workspace is running you cannot preview the CSV, which leaves you in a type of Catch-22 situation.

The solution is to temporarily hardcode a CSV filename, adjust the reader settings as necessary and then point the dataset parameter to "path_windows" again just before running the workspace.


sunsilk11
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • October 17, 2018
david_r wrote:

You cannot preview the file contents since FME cannot know the value of "path_windows" until the workspace is running. And when the workspace is running you cannot preview the CSV, which leaves you in a type of Catch-22 situation.

The solution is to temporarily hardcode a CSV filename, adjust the reader settings as necessary and then point the dataset parameter to "path_windows" again just before running the workspace.

Thanks for the response. Unfortunately this doesn't seem to work. When I replace the dataset by "path_windows", I don't get required output from FeatureReader.

 

See my workspace and sample csv attached.

 

 

samplefile.csv processlatestcsvinlist.fmw

 


david_r
Celebrity
  • Best Answer
  • October 17, 2018

A few things to look out for

  • If the filename is dynamic you need to configure the FeatureReader to use the <Generic> output port.
  • When using the <Generic> output port, do not specify "Feature types to read" as that will filter out any filenames that don't match that value.
  • When using the <Generic> output port, you'll have to manually expose the attributes returned by the CSV, such as "Lat", "Lon" etc.
  • The CSV parameters needs to be configured for Automatic attribute definition.

Example: processlatestcsvinlist.fmwt


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