<?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: Delete Feature Class by specific name from Geodatabase using arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1225244#M65936</link>
    <description>&lt;P&gt;Trying to delete feature classes by name if they exist.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Oct 2022 16:26:49 GMT</pubDate>
    <dc:creator>CCWeedcontrol</dc:creator>
    <dc:date>2022-10-25T16:26:49Z</dc:date>
    <item>
      <title>Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224328#M65915</link>
      <description>&lt;P&gt;I have a SDE feature data set with certain feature class I need to delete. I need to be able to delete them by name, because there are other feature class in there that I do not need to delete.&lt;/P&gt;&lt;P&gt;I have the following, it runs but it doesn't delete anything. I get no error either.&lt;/P&gt;&lt;P&gt;I am using this in a Calculate Value model.&lt;/P&gt;&lt;P&gt;Expression&lt;/P&gt;&lt;P&gt;FEMA1()&lt;/P&gt;&lt;P&gt;Code block&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os 

def FEMA1():

    arcpy.env.workspace = r"C:/Users/***/AppData/Roaming/Esri/ArcGISPro/Favorites/***.sde/CCDS.CCDS.TempLyrs"
    cws = arcpy.env.workspace

    fc_Delete = ["CCDS.CCDS.FEMA_FLOOD_ZONES_Temp","CCDS.CCDS.FLOODWAY_Temp","CCDS.CCDS.LOMAs_Temp","CCDS.CCDS.LOMRs_Temp","CCDS.CCDS.FEMA_Cross_Sections_Temp","CCDS.CCDS.FEMA_Base_Flood_Elevations_Temp", "CCDS.CCDS.FEMA_PANELS_Temp"]

    for fc in fc_Delete:
        fc_path = os.path.join(cws, fc)
        if arcpy.Exists(fc_path):
            arcpy.Delete_management(fc_path)
        else:
            return ("Feature classes do not exist")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 17:30:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224328#M65915</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-10-21T17:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224336#M65916</link>
      <description>&lt;P&gt;I'm not entirely familiar with this arcpy command, but it looks like the error is that there is no reference to the Return value of the arcpy.Exists line of your code. It should be formatted so that if the return value is the boolean value for True that the next line of code runs or skips if it is not true.&lt;/P&gt;&lt;P&gt;-Derek Wood&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 17:56:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224336#M65916</guid>
      <dc:creator>drWood</dc:creator>
      <dc:date>2022-10-21T17:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224348#M65917</link>
      <description>&lt;P&gt;There must be some formatting issue with the path of the feature class. Try running this as a standalone script and tinker with the path until you figure out the problem.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

arcpy.env.workspace = r"C:/Users/***/AppData/Roaming/Esri/ArcGISPro/Favorites/***.sde/CCDS.CCDS.TempLyrs"
cws = arcpy.env.workspace
fc_known_to_exist = os.path.join(cws, "CCDS.CCDS.FEMA_FLOOD_ZONES_Temp")
if arcpy.Exists(fc_known_to_exist):
    print(f"The feature class exists: {fc_known_to_exist}")
else:
    print(f"{fc_known_to_exist} does NOT exist.")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 Oct 2022 18:14:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224348#M65917</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-10-21T18:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224377#M65918</link>
      <description>&lt;P&gt;Adding on to this: is the "CCDS.CCDS.TempLyrs" in your workspace string a Dataset?&lt;/P&gt;&lt;P&gt;First thing I would try is to remove it, as I don't think it's needed.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 19:37:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224377#M65918</guid>
      <dc:creator>dgiersz_cuyahoga</dc:creator>
      <dc:date>2022-10-21T19:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224409#M65920</link>
      <description>&lt;P&gt;Expression/Code Block.&amp;nbsp; Looks like maybe you are trying to run this in the Calculate Field tool?&lt;/P&gt;&lt;P&gt;Are you trying to delete feature class(es) or update the value in an attribute table or both?&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 21:33:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224409#M65920</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-10-21T21:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224645#M65922</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/49959"&gt;@CCWeedcontrol&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I am using this in a Calculate Value model.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This needs to be in a script tool or somewhere else other than in a Calculate Field operation.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field.htm" target="_blank" rel="noopener"&gt;Calculate Field&lt;/A&gt; only calculates the values of a field for a feature class, feature layer, or raster.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 12:51:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1224645#M65922</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-10-24T12:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1225243#M65935</link>
      <description>&lt;P&gt;That is what I figured. So if I had to do this in model builder how would I go about it?&lt;/P&gt;&lt;P&gt;I've tried creating a model using a "If data Exists" and Iterate Feature class but was unsuccessful.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 16:26:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1225243#M65935</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-10-25T16:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1225244#M65936</link>
      <description>&lt;P&gt;Trying to delete feature classes by name if they exist.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 16:26:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1225244#M65936</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-10-25T16:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Feature Class by specific name from Geodatabase using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1225245#M65937</link>
      <description>&lt;P&gt;Code does run fine as standalone script.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 16:27:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-feature-class-by-specific-name-from/m-p/1225245#M65937</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-10-25T16:27:11Z</dc:date>
    </item>
  </channel>
</rss>

