Skip to main content
Solved

How to save the writer to a certain location based on the root folder of the source dataset?

  • December 22, 2022
  • 4 replies
  • 50 views

joy
Enthusiast
Forum|alt.badge.img+15
  • Enthusiast
  • 88 replies

Hello everyone,

For example, I have the following pathname of the source dataset

C:\\Temp\\FME Workbenches\\Kabelleidingen\\Klic\\Klicdata.dgn

 

Then I would like to write the end result of the script to the following

location.

C:\\Temp\\FME Workbenches\\Kabelleidingen\\Klic\\KlicData_analysis

So partly I want to write the data away to the root folder of the source dataset.

Does anyone know how I can achieve that?

The question is thus how I can get the value of the rootfolder that I subsequently can use in the writer.

Best answer by dustin

You can use a StringSearcher to extract the root folder from the fme_dataset format attribute using this regex (you'll need to expose fme_dataset on your reader):

.*\\

imageThen on your writer, you can set the fanout parameter to _first_match:

imageYou can also append an additional directory to the end of the extracted root folder if needed:

image

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, 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.

4 replies

dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • Best Answer
  • December 22, 2022

You can use a StringSearcher to extract the root folder from the fme_dataset format attribute using this regex (you'll need to expose fme_dataset on your reader):

.*\\

imageThen on your writer, you can set the fanout parameter to _first_match:

imageYou can also append an additional directory to the end of the extracted root folder if needed:

image


joy
Enthusiast
Forum|alt.badge.img+15
  • Author
  • Enthusiast
  • 88 replies
  • December 22, 2022

You can use a StringSearcher to extract the root folder from the fme_dataset format attribute using this regex (you'll need to expose fme_dataset on your reader):

.*\\

imageThen on your writer, you can set the fanout parameter to _first_match:

imageYou can also append an additional directory to the end of the extracted root folder if needed:

image

@dustin​ Thank you for the steps. I am only stuck what to fill in the "Fanout Destination Directory". I fill in "@value(_first_match) for this one and for the fanout directory @value(fme_basename)_analysis.

However instead of using the _first_match to find the pathname, it creates a new map called @value(_first_name). See image below. In my case I would like to put the destinatoin file in the folder Klic Stephensonstraat_22O12280 instead. So I am wondeirng why it's not recognizing the _first_match value, while I provide that value to the writer. It also doesn't recognize the fme_basename value, since only the addition _Bomenanalyse is filled in the name of the destination dataset. Do you might have an idea what the cause might be?imageimage


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • December 22, 2022

@scarter​ @Value needs to be capitalized. 

@Value(_first_name)

If you use the attribute value link to input the attribute, it should fill it out correctly. Or you can also use the Open Text Editor.image


joy
Enthusiast
Forum|alt.badge.img+15
  • Author
  • Enthusiast
  • 88 replies
  • December 22, 2022

@scarter​ @Value needs to be capitalized. 

@Value(_first_name)

If you use the attribute value link to input the attribute, it should fill it out correctly. Or you can also use the Open Text Editor.image

Hi @dustin​ the problem was that the information fme_dataset en _first_match was not available, since I just added the output of the stringsearcher to the writer. By using the featuremerger beforehand, therefore all feature got that value and the file could be written to the specifc map and name. Thank you for pointing me in the right direction