Skip to main content

Is there any transformer that help me to change from any of the python valid formats for GUIDs to the arcpy valid format to insert it in the geodatabase?

The valid formats from python are:

{00010203-0405-0607-0809-0a0b0c0d0e0f}

00010203-0405-0607-0809-0a0b0c0d0e0f

000102030405060708090a0b0c0d0e0f

{000102030405060708090a0b0c0d0e0f}

the valid format received by the geodatabase is:

{00010203-0405-0607-0809-0a0b0c0d0e0f}

 

thanks!!

 

 

If you have a GUID field in your Geodatabase writer, you can generate a value suitable for writing using Python e.g. like this:

import uuid
feature.setAttribute('MY_GUID', str(uuid.uuid4()))

The MY_GUID value will be on this format: '5a35172e-071f-4a33-b191-172a9b4b02ae'

If you need curly braces, replace the second line with this:

feature.setAttribute('MY_GUID', '{' + str(uuid.uuid4()) + '}')

If you have a GUID field in your Geodatabase writer, you can generate a value suitable for writing using Python e.g. like this:

import uuid
feature.setAttribute('MY_GUID', str(uuid.uuid4()))

The MY_GUID value will be on this format: '5a35172e-071f-4a33-b191-172a9b4b02ae'

If you need curly braces, replace the second line with this:

feature.setAttribute('MY_GUID', '{' + str(uuid.uuid4()) + '}')

@david_r thanks for your answer, but as I state in my question the allowed format received for the geodatabase must include curly braces.


@david_r thanks for your answer, but as I state in my question the allowed format received for the geodatabase must include curly braces.

Weird, I've never needed the curly braces when writing to either of the Geodatabase writers, but I've modified my answer with an option to include the braces, if needed.


Extending the answer from @david_r the proper implementation would be to generate the valid value with python:

import uuid
validGuid =  "{{{0}}}".format(str(uuid.UUID(cell_value)))
feature.setAttribute('VALID_GUID', validGuid)

 

 


Weird, I've never needed the curly braces when writing to either of the Geodatabase writers, but I've modified my answer with an option to include the braces, if needed.

row = rows.newRow(); row.setValue("MyField", '00010203-0405-0607-0809-0a0b0c0d0e0f'); rows.insertRow(row)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\arcobjects\arcobjects.py", line 2440, in setValue
    return convertArcObjectToPythonObject(self._arc_object.SetValue(*gp_fixargs(args)))
RuntimeError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
A general error when something is wrong with a Field. oMyfield]

row = rows.newRow(); row.setValue("MyField", '00010203-0405-0607-0809-0a0b0c0d0e0f'); rows.insertRow(row)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\arcobjects\arcobjects.py", line 2440, in setValue
    return convertArcObjectToPythonObject(self._arc_object.SetValue(*gp_fixargs(args)))
RuntimeError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
A general error when something is wrong with a Field. rMyfield]

Thanks for the info, somehow I didn't catch you were using arcpy, which explains why you need the curly braces. 


Reply