AnsweredAssumed Answered

Extracting from attribute tables by arcpy

Question asked by master.florin on Apr 27, 2015
Latest reply on Apr 28, 2015 by master.florin

I'm having some trouble connecting ideas on how to solve a problem. What I have is a shapefile from which I have to extract from one field, which contains 3 types of attributes (BS, RS, BRN). For each of those attributes, I've created a geodatabase and separate feature classes using another script.

I short, attributes have to go to their specific designation e.g. BS values go to feature BS, RS values etc.

My first guess is that I have to use Cursors to do it, but in this case I have to use both Search and Insert and how would I do that?

Would it make sense a start such as this?

 

import arcpy

shape = "D:/M1 Geomatique/Programmation II/Dossier/ZONE_INONDATION_SYNTHESE_67.shp"
gdb = "D:/M1 Geomatique/Programmation II/Dossier/inondation.gdb"
field = "CODE_DEGRE"
entite1 = "rs"
entite2 = "bs"
entite3 = "brn"

rows = arcpy.InsertCursor(gdb)
cursor = arcpy.SearchCursor(shape)

 

Perform a loop start with a SearchCursor followed by an InsertCursor could be a solution ? :

e.g.

with arcpy.da.SearchCursor(sourceFC,fieldnames) as sCur: 

     with arcpy.da.InsertCursor(targetFC,fieldnames) as iCur:

Above is just an example I've picked up on stackexchange

 

How would you advise me to tackle this problem?

Outcomes