Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Search Cursor against date field and using date with python

$
0
0
Good Afternoon ArcPy Wizards!

I would love some input on my code.
I am trying to capture the earliest positive in a grid and then count the negative sample that were required before the positive.

The Code:

Code:

for grid in grids:
        dates = []
        arcpy.SelectLayerByLocation_management("cwdpts4Anlys", "WITHIN", grid.shape, "NEW_SELECTION")
        positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" ')

        for positive in positives:
            dates.append(row[0])
       
        earliest = min(dates)
        arcpy.SelectLayerByLocation_management("cwdpts4Anlys", "WITHIN", grid.shape, "NEW_SELECTION")
        arcpy.SelectLayerByAttribute_management("cwdpts4Anlys", "SUBSET_SELECTION", ' "ELISALYMPHNODE" = \'Negative\' ')
        arcpy.SelectLayerByAttribute_management("cwdpts4Anlys","SUBSET_SELECTION",'"SAMPLE_DATE" <= date earliest ' )
        negatives = int(arcpy.GetCount_management("cwdpts4Anlys").getOutput(0))
        grid.setValue('NegPrior2Pos', negatives)
        grids.updateRow(grid)

I get a syntax error at
Code:

positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" ')
Ive tried adding the keyword date before "SAMPLE_DATE" and many other ways.

Thanks!
Alicia

Viewing all articles
Browse latest Browse all 2485

Trending Articles