Solved

Pass attribute value to FeatureReader

  • 16 October 2018
  • 3 replies
  • 16 views

Badge +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

icon

Best answer by david_r 17 October 2018, 12:17

View original

3 replies

Userlevel 4

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.

Badge +6

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

 

Userlevel 4

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

Reply