<?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: Need help building my first script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453356#M35559</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;or you can't have ,, in a row, something has to be inbetween&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Mar 2016 20:53:22 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-03-28T20:53:22Z</dc:date>
    <item>
      <title>Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453347#M35550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I'm trying to build a script, my first, so that it would create another version of some polygons in a shapefile (per example zoning)by erasing some polygons contained in a different shapefile (called hydro). I don't have a Pro license, so I use the "Union then delete" method instead of the erase tool. I don't want the attributes from the hydro table. I want to duplicate the script to apply those modification to other shapefiles. So here is what I found for the moment:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Import the system modules&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Set the current workspace&lt;/P&gt;&lt;P&gt;# (to avoid having to specify the full path to the feature classes each time)&lt;/P&gt;&lt;P&gt;env.workspace = "c:/data/data.gdb"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# For first layer&lt;/P&gt;&lt;P&gt;&amp;nbsp; #Turn off all fields of hydro.shp so when union is done, the attributes table will only keep the fields from "zoning", leaving out the turned off fields of "hydro" &lt;/P&gt;&lt;P&gt;&amp;nbsp; #Can't find script lines for that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; #union layerName with hydro.shp&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; #Source:&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fhelp.arcgis.com%2FEn%2FArcgisdesktop%2F10.0%2FHelp%2Findex.html%23%2F%2F00080000000s000000" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/En/Arcgisdesktop/10.0/Help/index.html#//00080000000s000000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; arcpy.Union_analysis (["layerName", "hydro", "layerName_union", "ALL")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; #select FID_hydro &amp;lt;&amp;gt; -1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; #Source: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fhelp.arcgis.com%2FEn%2FArcgisdesktop%2F10.0%2FHelp%2Findex.html%23%2F%2F001700000071000000" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/En/Arcgisdesktop/10.0/Help/index.html#//001700000071000000&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; arcpy.SelectLayerByAttribute_management ("layerName_union", "NEW_SELECTION", " [FID_hydro] &amp;lt;&amp;gt; '-1' ")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; #If selection &amp;gt; 0, delete FID_hydro &amp;lt;&amp;gt; -1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; #Source:&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fhelp.arcgis.com%2FEN%2FARCGISDESKTOP%2F10.0%2FHELP%2Findex.html%23%2F%2F001700000036000000" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/EN/ARCGISDESKTOP/10.0/HELP/index.html#//001700000036000000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if int(arcpy.GetCount_management(layerName_union).getOutput(0)) &amp;gt; 0:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DeleteFeatures_management(layerName_union)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; #export data layerName_union as shapefile&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; #Source:&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fresources.arcgis.com%2Fen%2Fhelp%2Fmain%2F10.1%2Findex.html%23%2F%2F001200000020000000" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000020000000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion("layerName_union","C:/Chemin/vers/dossier","layerName_noHydro.shp")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Repeat for other layers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone know how to use script to turn off all the field of a layer?&lt;/P&gt;&lt;P&gt;Would those steps work? Is there something missing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 16:19:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453347#M35550</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-03-28T16:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453348#M35551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you're looking for the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/delete-field.htm"&gt;Delete Field&lt;/A&gt; tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need more help, please include your code within code tags so we can copy/paste/more easily read. &lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 16:42:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453348#M35551</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-03-28T16:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453349#M35552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and featureclasstofeatureclass allows you to remove fields during the fieldmapping process &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/conversion-toolbox/feature-class-to-feature-class.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/conversion-toolbox/feature-class-to-feature-class.htm"&gt;Feature Class to Feature Class—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 16:43:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453349#M35552</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-28T16:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453350#M35553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Antoine,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To reiterate what others said, consider using the code block in the forum post:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;use Advanced Editor in the thread and click on the double arrows, go to syntax then Python:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;&lt;IMG __jive_id="193233" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/193233_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;I like the commenting you have done in your code, it helps for others to see. Have you tried running your code to see if it works? You may want to how you format your path strings. There are many different ways to do this, here are some examples:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;&lt;A __default_attr="2285" __jive_macro_name="polls" class="jive_macro_polls jive_macro" data-orig-content="How do you write Python path strings?" href="https://community.esri.com/"&gt;&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; font-family: Helvetica, sans-serif;"&gt;In your DeleteFeatures_Management, you do not have quotes around your layer name. From looking at other lines of code in your block, you will need those quotes. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 17:18:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453350#M35553</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-03-28T17:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453351#M35554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;# Import the system modules&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;import arcpy&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;from arcpy import env&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt; line-height: 12pt; font-family: arial, helvetica, sans-serif;"&gt;# Set the current workspace&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt; line-height: 12pt; font-family: arial, helvetica, sans-serif;"&gt;# (to avoid having to specify the full path to the feature classes each time)&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt; line-height: 12pt; font-family: arial, helvetica, sans-serif;"&gt;env.workspace = "c:/data/data.gdb"&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt; line-height: 12pt; font-family: arial, helvetica, sans-serif;"&gt;# For first layer&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;&lt;SPAN style="line-height: 12pt;"&gt;#Copy hydro.shp and delete all field of hydro_copy.shp so when union is done, the attributes table will only keep the fields from "zoning", leaving out the turned off fields of "hydro&lt;/SPAN&gt;&lt;SPAN style="line-height: 12pt;"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;arcpy.opyFeatures_management("hydro.shp", "C:/output/hydro_copy.shp")&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;arcpy.DeleteField_management("C:/output/hydro_copy.shp",["STREET_NAM", "LABEL", "CLASS"])&lt;/SPAN&gt;

&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt; #union layerName with hydro.shp&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt; line-height: 12pt; font-family: arial, helvetica, sans-serif;"&gt;acpy.Union_analysis (["layerName", "hydro", "layerName_union", "ALL")&lt;/SPAN&gt;

&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;#select FID_hydro &amp;lt;&amp;gt; -1&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;arcpy.SelectLayerByAttribute_management ("layerName_union", "NEW_SELECTION", " [FID_hydro] &amp;lt;&amp;gt; '-1' ")&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;#If selection &amp;gt; 0, delete FID_hydro &amp;lt;&amp;gt; -1&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt; if int(arcpy.GetCount_management(layerName_union).getOutput(0)) &amp;gt; 0:&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;arcpy.DeleteFeatures_management(layerName_union)&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt; line-height: 12pt; font-family: arial, helvetica, sans-serif;"&gt;#export data layerName_union as shapefile&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt; line-height: 12pt; font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion("layerName_union","C:/Chemin/vers/dossier","layerName_noHydro.shp")&lt;/SPAN&gt;

#ReaRepeat for other layers
#Repeat for other layers&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this better? Maybe it's my Chrome browser but the editor isn't friendly to use.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:13:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453351#M35554</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2021-12-11T20:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453352#M35555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would it looks like that? &lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14591931140679483 jive_macro_code jive_text_macro" data-renderedposition="34_8_1155_16" jivemacro_uid="_14591931140679483"&gt;&lt;P&gt;arcpy.FeatureClassToFeatureClass_conversion("Affectations_Union","C:\Users\Antoine\Desktop\test","layerName_shape.shp",,removeAll ())&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 19:25:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453352#M35555</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-03-28T19:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453353#M35556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;according to this &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/fieldmappings.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/fieldmappings.htm"&gt;FieldMappings—Help | ArcGIS for Desktop&lt;/A&gt; in scripting, I think that would be correct, but I am not at a machine to test at present&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 20:23:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453353#M35556</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-28T20:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453354#M35557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't seem to work, I get this message:&lt;/P&gt;&lt;P&gt;"Parsing error SyntaxError: invalid syntax (line 1)" !?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 20:38:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453354#M35557</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-03-28T20:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453355#M35558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;fms&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;FieldMappings&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;()&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;fms.removeAll()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;&lt;SPAN class="c" style="color: green; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; Create the output feature class, using the FieldMappings object&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;FeatureClassToFeatureClass_conversion&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;in_file&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;env&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;workspace&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;out_file&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;field_mapping&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;fms&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;guess-ta-coding from the help files&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="-webkit-font-smoothing: antialiased; color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; white-space: pre; -webkit-text-size-adjust: 100%; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 20:51:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453355#M35558</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-28T20:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453356#M35559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;or you can't have ,, in a row, something has to be inbetween&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 20:53:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453356#M35559</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-28T20:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453357#M35560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Antoine, there are a few typo errors in your code that you have posted (just briefly glancing through this, I see "opyFeatures_management" which is missing the letter "c". Also, for your path strings, you should put an "r" in front of the path to make it the raw path:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14591983932602915 jive_macro_code jive_text_macro" data-renderedposition="58.906246185302734_7.997159004211426_1332_15" jivemacro_uid="_14591983932602915"&gt;&lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;r"C:\Users\Antoine\Desktop\test"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;since it is reading it differently (looking at the "\t", etc.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What python editor are you using? You might consider something like PyCharm or PyScripter (both free) that will find errors like this and give suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 20:54:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453357#M35560</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-03-28T20:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453358#M35561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fms = arcpy.FieldMappings()
fms.removeAll()
arcpy.FeatureClassToFeatureClass_conversion("Lac","C:/Users/Antoine/Desktop/test","Lac_empty.shp","fms")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get this message now:&lt;/P&gt;&lt;P&gt;"Runtime error&amp;nbsp; Traceback (most recent call last):&amp;nbsp;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&amp;nbsp;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\conversion.py", line 1685, in FeatureClassToFeatureClass&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e ExecuteError: ERROR 999999: Error executing function. An invalid SQL statement was used. An invalid SQL statement was used. Failed to execute (FeatureClassToFeatureClass). "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I try to use the FeatureClassToFeatureClass tool, in the UI, I get another error message. I tried to solve it with &lt;A href="http://support.esri.com/en/knowledgebase/techarticles/detail/38099" rel="nofollow noopener noreferrer" target="_blank"&gt;this solution&lt;/A&gt;​. Still not working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:13:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453358#M35561</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2021-12-11T20:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453359#M35562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I corrected it and just downloaded PyCharm&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 21:42:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453359#M35562</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-03-28T21:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453360#M35563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the syntax I posted was&amp;nbsp; &lt;SPAN class="n" style="font-size: 12px; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; color: #4d4d4d; background-color: #fafafa;"&gt;field_mapping&lt;/SPAN&gt;&lt;SPAN class="o" style="font-size: 12px; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; color: #4d4d4d; background-color: #fafafa;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="n" style="font-size: 12px; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; color: #4d4d4d; background-color: #fafafa;"&gt;fms&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 12px; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; color: #4d4d4d; background-color: #fafafa;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You assigned it a text value "fms" which will surely fail.&amp;nbsp; Check the exact syntax in the help files and what the defaults are if you omit parameters.&amp;nbsp; You can't just omit parameters by using ,, or changing object properties ( a fieldmap is a type of object which is not a string object).&amp;nbsp; These errors aren't caught by IDE's, the clues are in the reported message, unfortunately they are interpreted with respect to the object expected and not by what the user expect to be given to solve the problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 22:15:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453360#M35563</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-28T22:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453361#M35564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I copied the wrong one. I tried yours at first, partly worked. I mean, a layer was saved as a new shape, but had the same fields as the original.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Mar 2016 23:38:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453361#M35564</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-03-28T23:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453362#M35565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is because it was an empty fms object, so it used the default - which is a complete field map that keeps all the fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Mar 2016 03:46:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453362#M35565</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2016-03-29T03:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453363#M35566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ &lt;A _jive_internal="true" class="localScroll font-color-meta-light" href="https://community.esri.com/thread/174590#comment-598117" title="Go to message" target="_blank"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;Antoine Cantin&lt;/SPAN&gt;&lt;/A&gt; &lt;SMALL&gt;&lt;SPAN style="font-size: 10pt;"&gt;on&lt;/SPAN&gt;&lt;/SMALL&gt; &lt;A _jive_internal="true" class="font-color-meta-light" href="https://community.esri.com/thread/174590#comment-598151" target="_blank"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;28-Mar-2016 4:51 PM&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P class="j-mark-correct js-mark-correct clearfix"&gt;&lt;A _jive_internal="true" class="js-action-link js-mark-correct-answer js-correct-answer-link" data-command="mark" data-object-id="598151" data-object-type="2" data-type="correct" href="https://community.esri.com/thread/174590" target="_blank"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;Mark Correct&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;DIV class="j-marked-correct"&gt;&lt;SPAN class="jive-icon-glyph icon-star3"&gt;&lt;/SPAN&gt;Correct Answer&lt;P&gt;ahhh perhaps...&lt;/P&gt;&lt;/DIV&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fm = arcpy.FieldMap()

fms = arcpy.FieldMappings() 
fms.removeAll()
fm.outputField = "out_stuff"
fms.addFieldMap(fm)
 #Create the output feature class, using the FieldMappings object 
arcpy.FeatureClassToFeatureClass_conversion( in_file, arcpy.env.workspace, out_file, field_mapping=fms)&lt;/PRE&gt;&lt;P&gt;might work but I would have to try it though... parsed from 2nd example here&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/fieldmappings.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/fieldmappings.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;FieldMappings—Help | ArcGIS for Desktop&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:13:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453363#M35566</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T20:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453364#M35567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I try it exactly like you posted I get an error message, but my guess is that I'm doing something wrong... What is the fm.outputField? Should I replace "out_stuff" by something?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Mar 2016 13:59:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453364#M35567</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-03-29T13:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453365#M35568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the field map output field... and it would be the name of the field you want to output... the example in the help topic seems reasonable, however, it might be best to go with Darren's deleting multiple fields... and providing all their names, or excluding the one you want to keep, ... than providing the name of the field or fields you want to keep.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Mar 2016 20:38:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453365#M35568</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-29T20:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help building my first script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453366#M35569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As a lazy coder, I would only use FieldMap and FieldMappings as a last resort. They are complete outliers in the context of arcpy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Mar 2016 20:48:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-building-my-first-script/m-p/453366#M35569</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-03-29T20:48:24Z</dc:date>
    </item>
  </channel>
</rss>

