473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 2053
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stephen Ferg | last post by:
I need a little help here. I'm developing some introductory material on Python for non-programmers. The first draft includes this statement. Is this correct? ...
14
by: Jive | last post by:
I've un-installed Python 2.4, re-installed Python 2.3 and PythonWin for 2.3, but it's still broke. When I start PythonWin, sometimes it looks like it is going to be okay. But as soon as I open...
0
by: Gabriel Cooper | last post by:
Usually when I access db search results it's something like this: cursor.execute("select A1,A2,A3,A4 from B where C") for (a1,a2,a3,a4) in cursor.fetchall(): stuff() But sometimes the point...
1
by: Gumby | last post by:
Does anyone know of an c++ code editor with this feature, supposing the cursor is inside functionX(), I'd like to be able to have the search for a string to look only in the scope of the { }. For...
10
by: Fred | last post by:
OK, I can now successfully enter data into my MySQL database through my CGI web page. I can click a button and retrieve all the records, but I can not seem to get the search code to work. ...
4
by: mathon | last post by:
Hello, im currently implementing a binary search tree means, that a greater number than root will be added as right child and a less number as left child. My insert function looks currently like...
1
by: mathon | last post by:
hi, now i facing a problem which i do not know how to solve it...:( My binary search tree structures stores a double number in every node, whereby a higher number is appended as right child...
3
by: archaegeo | last post by:
I am getting started in Python, and I have looked on both the stackless page and python.org and cannot find the answer to what I think is a simple problem. If I start the python command line or...
0
by: klia | last post by:
Hey guys; I am trying to develop a tiny program using python to search inside sqlite database with file extension is .db in which the program will ask users to enter their search query and base on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.