AnsweredAssumed Answered

Problem with select analysis + copy rows in loop

Question asked by kostas_ptr88 on Apr 3, 2015
Latest reply on Apr 8, 2015 by bixb0012

Hi, i am trying to implement various combinations of tools trying to export some rows  from a pnt shapefile based on a query (or while or for loop).I have a column (Condition) with values TRUE and FALSE and i want to export every row for the statement,  Condition = "TRUE". However i only want those rows who respond to TRUE and if a FALSE follows i don't want to export nothing else, although after FALSE maybe there are more TRUE.

an example:

 

FID  Condition    H    Wo                                                  FID  Condition                                        H         Wo
0      TRUE         65    20                                                     0      TRUE                                              65        20
1      TRUE         54    25                                                     1      TRUE                                              54        25
2      TRUE         54     0      I want only these values  --->   2      TRUE   with the rest of the fields    54         0
3      FALSE       65    25                                                                             
4      TRUE         98     0
5      TRUE         23     5

 

These are the samples of code i tried, to export the rows based my statement :

 

import arcpy, os

fc = "c:/Task/data/In.shp"

outworkspace = "c:/Task/data/In.shp"

fields = ["FID", "Condition", "H", "Wo"]

with arcpy.da.UpdateCursor(fc, fields) as cursor:

     for row in cursor:

         while [row] = 'TRUE':

         arcpy.CopyRows_management("In", "c:/Task/data/Out.shp")

 

 

and also with select analysis:

 

import arcpy, os

from arcpy import env

env.workspace = "c:/Task/data/In.shp"

fc = "c:/Task/data/In.shp"

fields = ["FID", "Condition", "H", "Wo"]

with arcpy.da.UpdateCursor(fc, fields) as cursor:

     for row in cursor:

         while [row] = 'TRUE':

         arcpy.Select_analysis("In", "Out_s", '[Condition] = "TRUE"'))

 

But for some reason i always get an error.

Outcomes