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:
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.
Solved! Go to Solution.
Also a good point, Blake. Perhaps the ultimate solution is to post the "correct" answer as an edit at the bottom of your original question, mark as correct the person who gave the closest answer, and give a helpful to everyone who contributed. Poor Kon! He will feel like he can't do anything right!
I think we will have to agree to disagree on this one. Unless an OP got little to no feedback and researched the answer himself/herself, taking functional code snippets from responses and repackaging them into a "final" answer seems like an easy way to abuse the point system. Part of the learning process is reading the whole discussion and understanding what comment was the crux of the solution. I really wish GeoNet's points and discussions were structured more like StackExchange/Overflow, but we have to make due with what we have before us.