470,849 Members | 1,287 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

search cursor in pythonwin 2.1

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.GpDisp atch.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

Feb 18 '07 #1
3 1975
En Sun, 18 Feb 2007 13:12:20 -0300, GISDude <gi*********@gmail.com>
escribió:
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.

--
Gabriel Genellina

Feb 18 '07 #2
On Feb 18, 2:19 pm, "Gabriel Genellina" <gagsl...@yahoo.com.arwrote:
En Sun, 18 Feb 2007 13:12:20 -0300, GISDude <gisdudes...@gmail.com>
escribió:
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.

--
Gabriel Genellina
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

Feb 19 '07 #3
En Mon, 19 Feb 2007 12:21:27 -0300, GISDude <gi*********@gmail.com>
escribió:
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...

--
Gabriel Genellina

Feb 20 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Stephen Ferg | last post: by
14 posts views Thread by Jive | last post: by
reply views Thread by Gabriel Cooper | last post: by
4 posts views Thread by mathon | last post: by
1 post views Thread by mathon | last post: by
3 posts views Thread by archaegeo | last post: by
reply views Thread by klia | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.