Solved

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

  • 22 December 2022
  • 4 replies
  • 0 views

Badge +13
  • Contributor
  • 56 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.

icon

Best answer by dustin 22 December 2022, 14:47

View original

4 replies

Userlevel 3
Badge +26

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

Badge +13

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

Userlevel 3
Badge +26

@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

Badge +13

@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

Reply