<?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: Feature Class to feature class failing on second iteration in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755760#M58304</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌, your first bullet point was actually correct. It didn't occur to me until just now, because I'd previously used a longer function that did rename the feature class. Didn't take that into account when I refactored the code. Once I checked and renamed k when sfc = Chatham, it ran fine. It would be nice if ESRI actually had a specific exception class for this, instead of handing it to a generic 999999 ExecuteError exception, but oh well. Thanks for your help. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Nov 2014 17:16:20 GMT</pubDate>
    <dc:creator>Zeke</dc:creator>
    <dc:date>2014-11-21T17:16:20Z</dc:date>
    <item>
      <title>Feature Class to feature class failing on second iteration</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755755#M58299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got two feature classes, one with data for four counties, and one with data for just one of the counties. I extract data from these feature classes into new feature classes in other feature datasets via arcpy.FeatureClasstoFeatureClass. The calling code is the first code block below. The relevant code for extractFeatures() is in the second code block&lt;/P&gt;&lt;P&gt;The the new feature class names, and the expressions used to extract them, are in tables. However, although they seem identical,AllCounties runs fine, but Chatham fails with a 999999 Execute Error function. A typical expression would be something like "FCC" LIKE 'H1%'. I've printed out all the values and they seem correct. I don't see any essential difference between one run through the code and another.&lt;/P&gt;&lt;P&gt;Can anyone see what's going wrong here? Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14165174313373032 jive_text_macro" jivemacro_uid="_14165174313373032" modifiedtitle="true"&gt;
&lt;P&gt;# CALLING CODE&lt;/P&gt;
&lt;P&gt;# tbls = dictionary of table name : feature dataset pairs&lt;/P&gt;
&lt;P&gt;# extract features for all four counties&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sfc = 'AllCounties'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tbls = {'BoundaryDefinitions' : 'Boundaries',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'TransportationDefinitions' : 'Transportation',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'HydroDefinitions' : 'Hydrology'}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for k, v in tbls.iteritems():&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; extractFeatures(k, sfc, v)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # extract features for Chatham County only. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sfc = 'Chatham'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tbls = {'BoundaryDefinitions' : 'ChathamBoundaries',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'TransportationDefinitions' : 'Chathamransportation',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'HydroDefinitions' : 'ChathamHydrology'}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for k, v in tbls.iteritems():&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; extractFeatures(k, sfc, v)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14165177108507557 jive_text_macro" jivemacro_uid="_14165177108507557" modifiedtitle="true"&gt;
&lt;P&gt;# in extractFeatures()&lt;/P&gt;
&lt;P&gt;# get feature class name/extraction expression pairs&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tbl = os.path.join(targetGDB, tblnm)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flds = ('Name', 'Definition') # field names in table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; defs = {}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(tbl, flds) as rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defs[row[0]] = row[1]&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # print error message and return empty dictionary to prevent further processing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; except exception as e:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s = '\n\tError: unable to retrieve values from {0}.\n\t{1}\n'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(s.format(tbl, e.message))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defs = {}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # data was returned from the definition table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if defs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sds = 'Framework'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; src = os.path.join(targetGDB, sds, sfc)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; target = os.path.join(targetGDB, tds)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for k, v in defs.iteritems():&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(src, target, k, v)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print('\tExtracted {0} from {1} to {2}.'.format(k, sfc, tds))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception as e:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s = '\tError: {0} not extracted. Halting extraction of {1} features.\n\t{2}'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(s.format(k, tds, e.message))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 21:18:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755755#M58299</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-11-20T21:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Class to feature class failing on second iteration</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755756#M58300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a question; in the first code block on line 15, is the feature dataset really called "Chathamransportation" or is there a "T" missing (Chatham&lt;STRONG&gt;T&lt;/STRONG&gt;ransportation)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error occurs on what line?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 21:33:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755756#M58300</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-11-20T21:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Class to feature class failing on second iteration</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755757#M58301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt; , that's just a typo when I copied the code over. The error occurs on line 24 of the 2nd code block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.FeatureClassToFeatureClass_conversion(src, target, k, v)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I've printed all the values, they all appear to be correct. The only thing I can think is that the sql expression, v above, is incorrect, but they're the same in the AllCounties version which does work. They come from the same tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 22:48:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755757#M58301</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-11-20T22:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Class to feature class failing on second iteration</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755758#M58302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the query definition at the moment the code crashes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# src: targetGDB\sds\sfc&lt;/P&gt;&lt;P&gt;# target: targetGDB\tds&lt;/P&gt;&lt;P&gt;# k: name&lt;/P&gt;&lt;P&gt;# v: where clause&lt;/P&gt;&lt;P&gt;# FeatureClassToFeatureClass_conversion (in_features, out_path, out_name, {where_clause})&lt;/P&gt;&lt;P&gt;arcpy.FeatureClassToFeatureClass_conversion(src, target, k, v)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't see anything strange in your code, but here are some questions/reasons for this to go wrong:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Is the output featureclass name unique in the geodatabase (no only in the feature dataset)?&lt;/LI&gt;&lt;LI&gt;Is the where clause correct?&lt;/LI&gt;&lt;LI&gt;Do you have a selection?&lt;/LI&gt;&lt;LI&gt;Does the where clause return results?&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 23:32:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755758#M58302</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-11-20T23:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Class to feature class failing on second iteration</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755759#M58303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;UL&gt;&lt;LI&gt;Yes, the feature class name is unique. To be precise, it overwrites an existing one, but env..overwriteOutput is True&lt;/LI&gt;&lt;LI&gt;The where clause should be correct, since it works for AllCounties. Almost all the where clauses are in the format "FCC" LIKE 'H1%', (the letter/number changes for different feature classes). This string is stored in the Definitions field of the relevant table.&lt;/LI&gt;&lt;LI&gt;No selection, this is all done in a stand-alone script.&lt;/LI&gt;&lt;LI&gt;I guess I don't know if the where clause returns results. I don't know why it wouldn't, since it does for AllCounties, which has the same schema as Chatham. AllCounties is just a merge of Chatham and three other counties, all same schema.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If both AllCounties &lt;STRONG&gt;and&lt;/STRONG&gt; Chatham failed I might have a path to understanding what went wrong, but since one works and the other doesn't, I'm at a loss. I've tried running Chatham first, but that doesn't work either.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 13:28:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755759#M58303</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-11-21T13:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Class to feature class failing on second iteration</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755760#M58304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌, your first bullet point was actually correct. It didn't occur to me until just now, because I'd previously used a longer function that did rename the feature class. Didn't take that into account when I refactored the code. Once I checked and renamed k when sfc = Chatham, it ran fine. It would be nice if ESRI actually had a specific exception class for this, instead of handing it to a generic 999999 ExecuteError exception, but oh well. Thanks for your help. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 17:16:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755760#M58304</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-11-21T17:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Class to feature class failing on second iteration</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755761#M58305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am glad you figured it out and could resolve your problem. There are certainly a "few" enhancements that could be made with the exceptions. A generic error doesn't help much...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 17:39:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-to-feature-class-failing-on-second/m-p/755761#M58305</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-11-21T17:39:47Z</dc:date>
    </item>
  </channel>
</rss>

