Skip to main content
Solved

Field Calculate in FME

  • October 31, 2018
  • 3 replies
  • 303 views

Forum|alt.badge.img

Hello,

I have a .cal file saved in python to create a unique identifier. How can I use this in FME? I didn't create this so I don't know how to tie this to the field needed.

In Arcmap I could just right click the field I want this to go in and field calculate it, but how would I use this to update attributes with nulls in a specific field within fme.

 

import uuid

def f():

 

return "{" + str(uuid.uuid4()).upper() + "}"

__esri_field_calculator_splitter__

f()

 

 

 

 

Best answer by david_r

In a PythonCaller you can do:

import uuid
def FeatureProcessor(feature):
    value = uuid.uuid4()
    feature.setAttribute('my_uuid', '{%s}' % value)

This will add the attribute 'my_uuid' to every feature that passes through.

 

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.

3 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • October 31, 2018

I believe the PythonCaller transformer could call this script.


david_r
Celebrity
  • 8394 replies
  • Best Answer
  • October 31, 2018

In a PythonCaller you can do:

import uuid
def FeatureProcessor(feature):
    value = uuid.uuid4()
    feature.setAttribute('my_uuid', '{%s}' % value)

This will add the attribute 'my_uuid' to every feature that passes through.

 


Forum|alt.badge.img
  • Author
  • 2 replies
  • October 31, 2018

Ended up using UUID generator instead of the python script in combination with Attributemanager.