<?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 Re: Check for certain field name and field type doesn't work in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/check-for-certain-field-name-and-field-type-doesn/m-p/1254252#M66766</link>
    <description>&lt;P&gt;Thank you ...&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2023 08:55:46 GMT</pubDate>
    <dc:creator>JohannesBierer</dc:creator>
    <dc:date>2023-02-02T08:55:46Z</dc:date>
    <item>
      <title>Check for certain field name and field type doesn't work</title>
      <link>https://community.esri.com/t5/python-questions/check-for-certain-field-name-and-field-type-doesn/m-p/1254226#M66764</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to check if a field type is text to change this field to type double so that I can use it as input field into XYTableToPoint?&lt;/P&gt;&lt;P&gt;This if statement in line 16 doesn't work (arcgis pro 3.0 notebook)&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Error message for line 41:&lt;/P&gt;&lt;PRE&gt;ERROR 000308: Ungültiger Feldtyp&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for f in files_list:
    print (f)
    
    outTable = "tab_" + os.path.splitext(os.path.basename(f.replace("-", "_")))[0]
    outXY =  "s_" + os.path.splitext(os.path.basename(f.replace("-", "_")))[0]

    arcpy.conversion.ExcelToTable(f, outTable)
        
    x = "R_Wert"
    y = "H_Wert"
    
    fields = arcpy.ListFields(outTable)
    field_names = []
    for field in fields:
        field_names.append(field.name)
        if field.name == x and field.type == "TEXT":
            
            print("Wrong type")
            
            arcpy.management.AddField(outTable, "R_Wert_1", "DOUBLE")
            arcpy.management.CalculateField(outTable, "R_Wert_1", 
                                '!R_Wert!', "PYTHON3")
            x = "R_Wert_1"
                    
        elif field.name == y and field.type == "TEXT":
            
            print("Wrong Type")
            
            arcpy.management.AddField(outTable, "HWert_1", "DOUBLE")
            arcpy.management.CalculateField(outTable, "R_Wert_1", 
                                '!H_Wert!', "PYTHON3")
            y = "H_Wert_1"
            
        else:
            continue    
    
    if x in field_names and y in field_names:
        
        print("Field names ok")
        
        arcpy.management.XYTableToPoint(outTable, outXY,
                                        x, y, "",
                                        arcpy.SpatialReference("DHDN 3-Degree Gauss Zone 3"))# ('ETRS 1989 UTM Zone 32N'))
        
        
    else:
        print("Field names wrong")
        continue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 07:39:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-for-certain-field-name-and-field-type-doesn/m-p/1254226#M66764</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2023-02-02T07:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Check for certain field name and field type doesn't work</title>
      <link>https://community.esri.com/t5/python-questions/check-for-certain-field-name-and-field-type-doesn/m-p/1254250#M66765</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/de/pro-app/latest/arcpy/classes/field.htm" target="_blank" rel="noopener"&gt;Field—ArcGIS Pro | Dokumentation&lt;/A&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Although the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Field&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;object's&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;type&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;property values are not an exact match for the keywords used by the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://pro.arcgis.com/de/pro-app/3.0/tool-reference/data-management/add-field.htm" target="_blank" rel="noopener"&gt;Add Field&amp;nbsp;&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;tool's&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;field_type&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;parameter, all of the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Field&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;object's&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;type&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;values can be used as input to this parameter. The different field types are mapped as follows:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Integer&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;LONG&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;String&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;TEXT&lt;/SPAN&gt;&lt;SPAN&gt;, and&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;SmallInteger&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;SHORT&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if field.name == x and field.type == "String"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 08:54:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-for-certain-field-name-and-field-type-doesn/m-p/1254250#M66765</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-02T08:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Check for certain field name and field type doesn't work</title>
      <link>https://community.esri.com/t5/python-questions/check-for-certain-field-name-and-field-type-doesn/m-p/1254252#M66766</link>
      <description>&lt;P&gt;Thank you ...&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 08:55:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-for-certain-field-name-and-field-type-doesn/m-p/1254252#M66766</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2023-02-02T08:55:46Z</dc:date>
    </item>
  </channel>
</rss>

