MS Access table values as input into a formula in another table-need help!!

Cathy James nambo4jb at gmail.com
Sun Jan 30 19:28:40 EST 2011


Dear Python Community,

Table1:
Prop_codeR_Value
GC 0.8
CI 0.6
LDR 0.4
HDR 0.6
TR 0.65
CR 0.35

Table 2:
O_ID PROP_CODE AI  TArea  R_Value Pre_R_Value IR
MER02006 LDR 38.19235 132.3178 0.4 0.115456 0.555143
MER02006 TR 20.78983 132.3178 0.65 0.102128 0.555143
MER02006 UO 1.850129 132.3178 0.25 0.003496 0.555143
MER03001 GC 16.565  137.592  0.8 0.096314 0.45027
Initially, I manually entered R_Value from table 1 into table 2 in order to
later compute subsequent fields using Python. Now I’d like to make the
process a bit more automatic. I would like to get R_Values  for each
Prop_Code  from table 1 into table 2 so that I can use them in a Table2
computation later on. I was thinking maybe a putting table 1 into a dict
then use those values in table 2, but I need help getting started. Just
learning Python and dicts are still tricky for me. Please help me modify the
code below so that i don't have to repeat the lines of code below for all
values of Prop_Code:
import arcpy,sys
arcpy.env.workspace = "C:\\test\\DRAINAGE.mdb"
Table1= "basins"
Table2="CV_Table"
cur = arcpy.UpdateCursor(table2, "[PROP_CODE] = 'LDR'")
row = cur.next()
# Perform the update and move to the next row as long as there are
#  rows left
while row:
    row.R_Value  = 0 #initialize field from nulls to zero values
    row.R_Value = 0.4 #INstead, I need to get this from Table 2
    cur.updateRow(row)
    row = cur.next()
# Delete the cursors to remove any data locks
del row, cur

THANKS!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110130/889f5e77/attachment.html>


More information about the Python-list mailing list