search cursor in pythonwin 2.1

GISDude gisdudester at gmail.com
Sun Feb 18 11:12:20 EST 2007


Hi all.
I am trying to create a little script(I think) that will basically use
a search cursor.

I am a GIS(geographic information systems) Analyst and in our
software(ESRI ARCGIS 9.1) ESRI has implemented Python 2.1 as the
scripting language of choice.

In my script I'm going thru a dbf file and extracting NON-NULL values
in a field. What I need to do with that is create a new dbf table with
the values I found in it.

Here is my sample code so far:
# This is a basic script for searching thru a table
# seeing if a field has a value, then writing that record
# to a brand new dbf
#
# Import basic modules
import win32com.client, sys, os, string


# Create the basic Geoprocessor Object
GP = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

# Make sure to setup proper licensce level from ESRI
GP.SetProduct("arcview")

# Set the input workspace - I WONT USE THE ARGUMENT DIALOG BOX
GP.Workspace = "E:/IntermediateGISProgrammingGEOG376/labs/
neighborhoods"



# THIS IS THE SPOT WHERE I'M MESSING UP
# I THINK AT THIS POINT I NEED TO:
# 1: OPEN THE SHAPEFILE
# 2: INITIALIZE THE FC VARIABLE
# 3: USE THE SEARCHCURSOR TO FIND THE RECORDS THAT HAVE A VALUE IN THE
NAME FIELD




# I looked in the Select Help file and a number of items popped up.
# However, I opened up Select -> analysis and it shows how to select
# from a shapefile. I assume this is what I need?
GP.Select_Analysis("neighborhoods.shp", "neighborhoods_names.shp", '
"Names" <> \ "null\" ')

                   #at this point I'm stuck. how do I query out a NON-
NULL value?
                   #or a value in the Names field?

Could anyone throw me a bone over here?

TIA




More information about the Python-list mailing list