Help With python script to delete multiple fields in multiple files but keep certain fields? (ArcGIS...

How can I safely use "Thalidomide" in my novel while respecting the trademark?

Why do Radio Buttons not fill the entire outer circle?

Proving an identity involving cross products and coplanar vectors

Grepping string, but include all non-blank lines following each grep match

Check if object is null and return null

The Digit Triangles

Air travel with refrigerated insulin

Language involving irrational number is not a CFL

Why didn't Voldemort know what Grindelwald looked like?

Quoting Keynes in a lecture

Why does the Persian emissary display a string of crowned skulls?

Why is the Sun approximated as a black body at ~ 5800 K?

When is "ei" a diphthong?

What is the meaning of the following sentence?

How do I tell my boss that I'm quitting in 15 days (a colleague left this week)

Can I run 125kHz RF circuit on a breadboard?

What (the heck) is a Super Worm Equinox Moon?

Should I warn new/prospective PhD Student that supervisor is terrible?

Sigmoid with a slope but no asymptotes?

How to make money from a browser who sees 5 seconds into the future of any web page?

When and why was runway 07/25 at Kai Tak removed?

Can you identify this lizard-like creature I observed in the UK?

Make a Bowl of Alphabet Soup

How do I fix the group tension caused by my character stealing and possibly killing without provocation?



Help With python script to delete multiple fields in multiple files but keep certain fields? (ArcGIS 10.5)


Dissolving shapefile python script not working, syntax help pleaseHelp with field calculator in Python scriptInvert Deleting multiple fields with delete tool in ArcGIS Desktop?conditional python script to delete recordsPython Script to Add Multiple Fields to Feature ClassesUpdating multiple fields with list values using arcpy.da.UpdateCursorHow do I delete duplicates based on multiple fieldsDuplicate Fields after Join with Python scriptSort by multiple fields and delete record with highest valueArcGIS 10.5 Python script integration to 'script/tool' not outputting data













0















I am needing to be able to run a python script on a folder full of shape files to delete multiple fields in the attribute tables. but i want to be able to keep 3 fields (Crop_Type, Acres, and Field_Name). the code included below was taken from another post on here however im unsure how to dedit it to keep the three fields that II want to keep along with the required fields that arcgis needs. I cant get it to run, not sure where to go from here any help is appreciated.



here is my current code



import arcpy
import os

arcpy.env.workspace = "D:Big Hill-East Gospel"
fcList = arcpy.ListFeatureClasses()

for fc in fcList:
desc = arcpy.Describe (fc)
#shape field name
shpFld = desc.shapeFieldName
#oid field
oidFld = desc.OIDFieldName
#shapefile name field
shpFileFld = os.path.splitext (fc) [0]
#list fields
delFlds = [f.name for f in arcpy.ListFields (fc)
if not f.name in [shpFld, oidFld, shpFileFld]]

#delete fields
arcpy.DeleteField_managemnet (fc, delFlds)








share







New contributor




Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I am needing to be able to run a python script on a folder full of shape files to delete multiple fields in the attribute tables. but i want to be able to keep 3 fields (Crop_Type, Acres, and Field_Name). the code included below was taken from another post on here however im unsure how to dedit it to keep the three fields that II want to keep along with the required fields that arcgis needs. I cant get it to run, not sure where to go from here any help is appreciated.



    here is my current code



    import arcpy
    import os

    arcpy.env.workspace = "D:Big Hill-East Gospel"
    fcList = arcpy.ListFeatureClasses()

    for fc in fcList:
    desc = arcpy.Describe (fc)
    #shape field name
    shpFld = desc.shapeFieldName
    #oid field
    oidFld = desc.OIDFieldName
    #shapefile name field
    shpFileFld = os.path.splitext (fc) [0]
    #list fields
    delFlds = [f.name for f in arcpy.ListFields (fc)
    if not f.name in [shpFld, oidFld, shpFileFld]]

    #delete fields
    arcpy.DeleteField_managemnet (fc, delFlds)








    share







    New contributor




    Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I am needing to be able to run a python script on a folder full of shape files to delete multiple fields in the attribute tables. but i want to be able to keep 3 fields (Crop_Type, Acres, and Field_Name). the code included below was taken from another post on here however im unsure how to dedit it to keep the three fields that II want to keep along with the required fields that arcgis needs. I cant get it to run, not sure where to go from here any help is appreciated.



      here is my current code



      import arcpy
      import os

      arcpy.env.workspace = "D:Big Hill-East Gospel"
      fcList = arcpy.ListFeatureClasses()

      for fc in fcList:
      desc = arcpy.Describe (fc)
      #shape field name
      shpFld = desc.shapeFieldName
      #oid field
      oidFld = desc.OIDFieldName
      #shapefile name field
      shpFileFld = os.path.splitext (fc) [0]
      #list fields
      delFlds = [f.name for f in arcpy.ListFields (fc)
      if not f.name in [shpFld, oidFld, shpFileFld]]

      #delete fields
      arcpy.DeleteField_managemnet (fc, delFlds)








      share







      New contributor




      Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I am needing to be able to run a python script on a folder full of shape files to delete multiple fields in the attribute tables. but i want to be able to keep 3 fields (Crop_Type, Acres, and Field_Name). the code included below was taken from another post on here however im unsure how to dedit it to keep the three fields that II want to keep along with the required fields that arcgis needs. I cant get it to run, not sure where to go from here any help is appreciated.



      here is my current code



      import arcpy
      import os

      arcpy.env.workspace = "D:Big Hill-East Gospel"
      fcList = arcpy.ListFeatureClasses()

      for fc in fcList:
      desc = arcpy.Describe (fc)
      #shape field name
      shpFld = desc.shapeFieldName
      #oid field
      oidFld = desc.OIDFieldName
      #shapefile name field
      shpFileFld = os.path.splitext (fc) [0]
      #list fields
      delFlds = [f.name for f in arcpy.ListFields (fc)
      if not f.name in [shpFld, oidFld, shpFileFld]]

      #delete fields
      arcpy.DeleteField_managemnet (fc, delFlds)






      arcgis-desktop arcpy arcmap python-2.7 arcgis-10.5





      share







      New contributor




      Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 mins ago









      Zbowlby017Zbowlby017

      1




      1




      New contributor




      Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Zbowlby017 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Zbowlby017 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f316203%2fhelp-with-python-script-to-delete-multiple-fields-in-multiple-files-but-keep-cer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Zbowlby017 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Zbowlby017 is a new contributor. Be nice, and check out our Code of Conduct.













          Zbowlby017 is a new contributor. Be nice, and check out our Code of Conduct.












          Zbowlby017 is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f316203%2fhelp-with-python-script-to-delete-multiple-fields-in-multiple-files-but-keep-cer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

          Meter-Bus Содержание Параметры шины | Стандартизация |...