Skip to main content
Hello,

 

 

 I am new to FME, recently started to work on FME Desktop 2014. I am looking to convert any format to CSV. My requirement is to deposite output CSV to same input folder.

 

 

e.g. If user selects c:\\temp\\test.shp then test.csv should be written to c:\\temp\\folder.

 

 

Currently I am able to convert the file but I am not able to set output path same as input path.

 

 

I am not sure how to achieve this.Any pointers in the right direction will be appreciated.

 

 

Regards,

 

john
Hi,

 

 

Your input shapefiles have a parameter $(SourceDataset_SHAPE) (see navigator panel)

 

If u create a attribute directory_out or something after parsing it from this parameter.

 

 

Or you can use a driectory and filename reader. To  do samish.
Thanks for your reply.

 

 

I can create directory_out attribute but how to assign it to DestDataset macro so that it will create csv in that folder.
Ah, i see.

 

 

create a scripted parameter (in my picture $out).

 

In the stringeditor of this scripted parameter you can make a link to the Sourcedataset.

 

You can extract the path in this editor, using regularexpression.

 

 

Then edit the parameter of the DestDataset_SHAPE and link it to the created parameter

 

 


Hi John,

 

 

Agree with Gio on defining a scripted parameter.

 

I'll give an example. A Scripted (Tcl) Parameter with this script provides the directory path of the source dataset.

 

-----

 

return tfile dirname $FME_MacroValues(SourceDataset_SHAPE)]

 

-----

 

Just be aware that this example is valid only when SourceDataset_SHAPE represents a single file path.

 

 

Takashi
another note i forgot to mention.

 

The definition of the $out parameter must be done prior to the referencing of this $out parameter.

 

This order you can set in the paramter section in the navigator panel, you can drag one above the other
alternatively, you can also change type of DestDataset_SHAPE parameter to "Scripted (Tcl)" and then define a script directly for the parameter 😉
with Takashi's tcl script it looks like this:

 

(zoom in a bit...)

 

 


..lol..

 

 

 

Takashi is of course right..more efficient to directly script the DestDataset.
Thanks Gio and Takashi... solution worked like charm.

Please could you provided the TCL script to define the folder output writer based on the file input reader name?

 

 

Thanks

@gio,

Please could share the script to perfom such task?

Thanks


Reply