Shapefile: "table1.shp"
- Field name: "Name"
- Field name: "Result"
Flat file: "referenceTable"
- Field name: "STREET"
- Field name: "AKA"
I need to compare the value "Name" in "table1.shp" to the value "STREET" in "referenceTable"
If the values are the same then put the "AKA" value into the "Result" in "table1.shp"
Here is my code. I got stuck on accessing the elements from the array
import arcpy, os, sys, string
from array import *
table1 = "G:\\xStreetNew\\table1.shp"
table1_column = ['Name', 'Result']
referenceTable = "G:\\xStreetNew\\Test.gdb\\referenceTable"
referenceTable_column = ['STREET', 'AKA']
referenceTable_List = []
with arcpy.da.SearchCursor(referenceTable, referenceTable_column) as rCur:
for r_row in rCur:
reference_row = r_row[0].split(",")
referenceTable_List.insert(0,reference_row)
##print sorted(referenceTable_List)
Table1_Update_Cursor = arcpy.da.UpdateCursor(table1, "Name")
for row in Table1_Update_Cursor:
if row[0] == None:
row[0] = row[0]
else:
row[0] = row[0].replace(";",",")
Table1_Update_Cursor.updateRow(row)
table1_List = []
with arcpy.da.SearchCursor(table1, table1_column) as tCur:
for t_row in tCur:
row = t_row[0].split(",")
table1_List.insert(0,row)
##print sorted(table1_List)
Table1_row = len(table1_List)
Table1_column = len([table1_List])
ref_row = len(referenceTable_List)
for i in range(0,Table1_row): #Table Row
for ii in range(0,Table1_column): #Table Column
print table1_List[i][ii]
Below was my old post. Sorry for the confusion.
I have a shapefile named "table1.shp".
- I would like to get all values from fielname "Name" from this table and put them into a list.
- Able to output each element from the list
So far, I'm able to create a list but not too sure how to get to value "AVENUE 33" or "CHAPMAN ST"
This is my code:
import arcpy, os, sys, string
from array import *
table1 = "G:\\xStreetNew\\table1.shp"
referenceTable = "G:\\xStreetNew\\Test.gdb\\referenceTable"
cursor = arcpy.da.UpdateCursor(table1, "Name")
for row in cursor:
if row[0] == None:
row[0] = row[0]
else:
row[0] = row[0].replace(";",",")
cursor.updateRow(row)
table1_column = ['Name']
table1_curObj = arcpy.da.SearchCursor(table1, table1_column)
table1_List = []
for row in table1_curObj:
table1_row = row[0].split(",")
table1_List.insert(0,table1_row)
print table1_List[0]