search cursor in pythonwin 2.1

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GISDude

    #1

    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("esri Geoprocessing.G pDispatch.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:/IntermediateGIS ProgrammingGEOG 376/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_Analy sis("neighborho ods.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

  • Gabriel Genellina

    #2
    Re: search cursor in pythonwin 2.1

    En Sun, 18 Feb 2007 13:12:20 -0300, GISDude <gisdudester@gm ail.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
    esriGeoprocessi ng object.
    GP.Select_Analy sis("neighborho ods.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

    Comment

    • GISDude

      #3
      Re: search cursor in pythonwin 2.1

      On Feb 18, 2:19 pm, "Gabriel Genellina" <gagsl...@yahoo .com.arwrote:
      En Sun, 18 Feb 2007 13:12:20 -0300, GISDude <gisdudes...@gm ail.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
      esriGeoprocessi ng object.
      >
      GP.Select_Analy sis("neighborho ods.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

      Comment

      • Gabriel Genellina

        #4
        Re: search cursor in pythonwin 2.1

        En Mon, 19 Feb 2007 12:21:27 -0300, GISDude <gisdudester@gm ail.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

        Comment

        Working...