Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Is there a way to simultaneously delete fields in Modelbuilder? I want to be able to remove excess fields from an iterative join of near tables. All of the fields I want to delete and keep are similarly named (ex: NEAR_FID). I have 40+ copies of that variables named this way in one table.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Just use the Delete Field tool.

This tool deletes one or more fields from a table, feature class, feature layer, or raster dataset.

After you get it linked up to your layer, it gives you checkboxes for all the fields you want to delete. If you they all start off with the same name (ie- NEAR_FID), you will probably end up seeing a series of NEAR_FID_1, NEAR_FID_2, NEAR_FID_3, etc). You run the Delete Field tool at the end of your model to clean up all of the fields you don't want.

share|improve this answer
1  
Just a heads up, as ModelBuilder has always been very finicky with me, you may not be able to select the fields if they are created during the model as they don't currently exist in the layer. If this happens you can create a text variable in the model as the output of the join and then the input of the delete. –  AlmaThom Jun 3 '13 at 19:04
    
thank you both. @almathom that was exactly the issue I was running into. is there anyway to be able to use wildcard with this tool? –  ajeedee Jun 3 '13 at 19:24
1  
If it is a static model, and you always expect to delete the same fields, every time, run the model (in ModelBuilder, not as a tool) UP TO THE STEP BEFORE THE DELETE FIELD TOOL, and when you open up the Delete Field tool (in your model), the new fields should now be visible. Pick you fields to delete and run the model to completion (still in Model view). If you save the model in the "completed" state, it will usually cache the field names for future use. –  RyanDalton Jun 3 '13 at 20:02

Without knowing how all of your fields are created in the model, a possible solution is to make a variable out of a tool parameter and then feed those variables into the Delete Field tool. This avoids the problem of the fields not being selectable directly through the Delete Field tool.
http://resources.arcgis.com/en/help/main/10.1/#/Exposing_tool_parameters_as_variables/002w0000003w000000/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.