search cursor in pythonwin 2.1

G

GISDude

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
 
G

Gabriel Genellina

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.

I think you should either read the ArcGis documentation, or post your
question in a specilized forum.
Your problem is not about Python itself, but on how to use the
esriGeoprocessing object.
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?

As a side note, on a standard SQL database, the condition would read
"Names IS NOT NULL", but I don't know if this is applicable or not.
 
G

GISDude

I think you should either read the ArcGis documentation, or post your
question in a specilized forum.
Your problem is not about Python itself, but on how to use the
esriGeoprocessing object.



As a side note, on a standard SQL database, the condition would read
"Names IS NOT NULL", but I don't know if this is applicable or not.

Gabriel,

Thanks for the reply. After looking at the docs again, you are correct
"NAMES" IS NOT NULL would be the correct syntax.

I thought it was "NAMES" <> NULL

Thanks again
 
D

Dennis Lee Bieber

Thanks for the reply. After looking at the docs again, you are correct
"NAMES" IS NOT NULL would be the correct syntax.

I thought it was "NAMES" <> NULL
No... in most languages with a NULL concept, something either is or
is not NULL.

NULL == NULL => False
and
NULL <> NULL => may depend on how <> is implemented
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
G

Gabriel Genellina

Thanks for the reply. After looking at the docs again, you are correct
"NAMES" IS NOT NULL would be the correct syntax.

I thought it was "NAMES" <> NULL

Python has some gotchas like default mutable arguments, that will catch
the novice. SQL has its NULL behavior on expressions...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top