Skip to main content
Solved

Field Calculate in FME

  • October 31, 2018
  • 3 replies
  • 256 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.

 

View original
Did this help you find an answer to your question?

3 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • October 31, 2018

I believe the PythonCaller transformer could call this script.


david_r
Evangelist
  • 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
  • October 31, 2018

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings