<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do I add a GUID from a string to a field in ArcPy? in ArcMap Questions</title>
    <link>https://community.esri.com/t5/arcmap-questions/how-do-i-add-a-guid-from-a-string-to-a-field-in/m-p/1046672#M2339</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am attempting to add a GUID field to the attribute table of a raster catalog using ArcPy.&lt;/P&gt;&lt;P&gt;This what I have tried, based on a couple online sources.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;def get_survey_id_guid(survey_id):
    return '{' + str(uuid.UUID(survey_id)).upper() + '}'


def add_survey_columns(mxd, layer, survey_id, survey_name):
    arcpy.AddField_management(layer, "survey_id", "GUID")
    arcpy.CalculateField_management(layer, "survey_id", "!survey_id! = {}".format(get_survey_id_guid(survey_id)), "PYTHON")
    mxd.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will create the survey_id field of type Guid, but it is populated with &amp;lt;null&amp;gt;.&lt;/P&gt;&lt;P&gt;How do I add the GUID to the field from a string?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Apr 2021 22:17:09 GMT</pubDate>
    <dc:creator>JesseTemplin2</dc:creator>
    <dc:date>2021-04-13T22:17:09Z</dc:date>
    <item>
      <title>How do I add a GUID from a string to a field in ArcPy?</title>
      <link>https://community.esri.com/t5/arcmap-questions/how-do-i-add-a-guid-from-a-string-to-a-field-in/m-p/1046672#M2339</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am attempting to add a GUID field to the attribute table of a raster catalog using ArcPy.&lt;/P&gt;&lt;P&gt;This what I have tried, based on a couple online sources.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;def get_survey_id_guid(survey_id):
    return '{' + str(uuid.UUID(survey_id)).upper() + '}'


def add_survey_columns(mxd, layer, survey_id, survey_name):
    arcpy.AddField_management(layer, "survey_id", "GUID")
    arcpy.CalculateField_management(layer, "survey_id", "!survey_id! = {}".format(get_survey_id_guid(survey_id)), "PYTHON")
    mxd.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will create the survey_id field of type Guid, but it is populated with &amp;lt;null&amp;gt;.&lt;/P&gt;&lt;P&gt;How do I add the GUID to the field from a string?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 22:17:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/how-do-i-add-a-guid-from-a-string-to-a-field-in/m-p/1046672#M2339</guid>
      <dc:creator>JesseTemplin2</dc:creator>
      <dc:date>2021-04-13T22:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a GUID from a string to a field in ArcPy?</title>
      <link>https://community.esri.com/t5/arcmap-questions/how-do-i-add-a-guid-from-a-string-to-a-field-in/m-p/1047386#M2343</link>
      <description>&lt;P&gt;Just needed extra quotes, so the CalculateField line ends up looking like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.CalculateField_management(layer, "survey_id", "'{}'".format(get_survey_id_guid(survey_id)), "PYTHON")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 15 Apr 2021 02:19:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/how-do-i-add-a-guid-from-a-string-to-a-field-in/m-p/1047386#M2343</guid>
      <dc:creator>JesseTemplin2</dc:creator>
      <dc:date>2021-04-15T02:19:47Z</dc:date>
    </item>
  </channel>
</rss>

