Skip to main content

I have a workflow that includes transformers and a Python caller. The output of the Python caller generates CSV, GeoJSON, and SHP writers. The workflow has a user parameter called OUTFIELDS, which specifies the fields that should be written. How can I achieve this? I tried using AttributeExploder, but I couldn't dynamically generate the list of fields.

Edit: It seems I misread your post

Hi, I always use a PythonCaller to expose attributes stored in a User Parameter:

This can also be done in a FeatureReader


Hope this helps!


Thank you for your response. I have already tried setting the user parameter for the Attribute to expose. During execution, I set $(OUTFIELDS) to "OBJECTID MILLESIME_DATA MILLESIME_DATA2", and I get all three fields in my output. However, when I change the value of $(OUTFIELDS) to "OBJECTID MILLESIME_DATA", I still see all three fields instead of just the two specified. Therefore, I'm looking for an alternative solution, if possible.


I think the way to do this is to use dynamic writing (define the attributes based on a schema feature).

One way to do this is to use the SchemaScanner to generate a SchemaFeature. You will then need to remove the attributes from the schema feature which are not in the outfields parameter.

===

Attached sample demonstrating this.

 


Thank you for your response. I have already tried setting the user parameter for the Attribute to expose. During execution, I set $(OUTFIELDS) to "OBJECTID MILLESIME_DATA MILLESIME_DATA2", and I get all three fields in my output. However, when I change the value of $(OUTFIELDS) to "OBJECTID MILLESIME_DATA", I still see all three fields instead of just the two specified. Therefore, I'm looking for an alternative solution, if possible.

Interesting, I have never seen this issue. It seems like the fields to be exposed in the PythonCaller are saved in memory or something. 
I always feed the field names into the User Parameter through a WorkspaceRunner. If the workspace is opened again (by rerunning the WorkspaceRunner), I guess the saved field names are reset.


@nielsgerrits Thank you for your example. I’ll try it and keep you informed.

@joepk It's very strange because when I reopen the application, it recognizes the new value of the user parameter. I tried publishing my workspace to FME Flow, but I still have the same issue.


Reply