I am trying to take a shapefile, with way too many fields/columns, and copy over only certain fields into a new shapefile.
Normally, I would just delete the fields I don't need from the original shapefile, but I don't want to come across an instance where the GIS operator decides to remove a field that my automated .py scripts is trying to delete, causing the program to fail.
At this point, I have not physically tried anything because every tool I have come across I have been able to find documentation proving it's lack of usefulness (Fields -> Transpose Field
and General -> Copy
).
Fields -> Transpose Field does copy individual fields but it transposes them from a column into a row appendage, which does not help.
General -> Copy copies the entire shapefile and will not let me choose only certain columns. What I want is something similar to this tool but one that will allow me to choose only certain fields to include in the copy.
I use "Feature Class To Shapefile (multiple)" to convert my features into shapefiles, and I tried looking into a "Feature to Shapefile" solo Tool that would let me pick the columns/attributes of the feature to convert. That has so far turned up empty as well.
I am using the ArcCatalog ModelBuilder to perform this task, not raw Python scripts. I know enough Python to go that route if needed, but a Toolbox Tool is the preferred goal. This task will be part of a larger whole that will be run via a batch file calling the exported Python code from the Models. It has to be something that can be run automatically, so manually copying/pasting is not applicable.
As for a screenshot of the Model, my current setup has each task as individual models: one model copies rows, one creates shapefile from feature class, one adds a field, one populates that field, etc. I'm sure this is probably inefficient but this task has been passed on to me from someone else and this was how it was done. I can add screenshots of the other models I have but I'm not sure what use that will provide, as it doesn't give much of a context.
Basically, I'm looking to do something like Copying data from one attribute field to another using ArcGIS Field Calculator? but with about 10 different fields. I don't want to do them individually, but using one or maybe two tools.
arcpy.DeleteField_management()
will not fail if told to delete a field that doesn't exist.