I am using a multivalue field parameter which is supposed to be used in a "keepList" of fields. Script makes a copy of a user defined feature class and deletes all fields from the copy except for required fields and fields from the "keepList". I am not receiving any run errors however, the fields I specify in the parameter don't show in the output feature class. What I have so far:
<SPAN class="comment token"># Appends fields detailed in the user input to keepList</SPAN>
Keep_Fields2 <SPAN class="operator token">=</SPAN> Keep_Fields<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">";"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> Keep_Fields2<SPAN class="punctuation token">:</SPAN>
keepList<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Deletes unnecesary fields from the Copy_KP </SPAN>
fieldNames <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>f<SPAN class="punctuation token">.</SPAN>name <SPAN class="keyword token">for</SPAN> f <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>Copy_KP<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>Fields <SPAN class="keyword token">if</SPAN> <SPAN class="operator token">not</SPAN> <SPAN class="punctuation token">(</SPAN>f<SPAN class="punctuation token">.</SPAN>type <SPAN class="keyword token">in</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"OID"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Geometry"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">or</SPAN> f<SPAN class="punctuation token">.</SPAN>name <SPAN class="keyword token">in</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Shape_Length"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Shape_Area"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">or</SPAN> f<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">.</SPAN>upper<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">in</SPAN> keepList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">if</SPAN> fieldNames<SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>DeleteField_management<SPAN class="punctuation token">(</SPAN>Copy_KP<SPAN class="punctuation token">,</SPAN> fieldNames<SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Notes: "Copy_KP" is the copied feature class variable. "Keep_Fields" is the the multivalue field parameter variable. The "keepList" is an empty list '[ ]' (I know this empty list may be redundant, however I have been experimenting with various methods of accomplishing this task). I am going to make the variables more intuitive after I get this thing working.