AnsweredAssumed Answered

Passing Value for Dictionary Look Up Fails

Question asked by ASorensen on Dec 21, 2014
Latest reply on Dec 22, 2014 by TomGeo

I've a field calculator that I am trying to use that uses a csv file to look up appropriate value based on key that is passed provided to the function. As provided below, the only values calculated are zero. The code itself is loading the data and working correctly. If I enter any number into final line of code instead of "elev" it calculates the appropriate value. If I just return "elev" to see if value is getting there, it calculates the correct values. When I try the code as below, I can't get it to return the right values. Any suggestions would be appreciated.

Using ArcGIS 10.2 at ArcInfo level

What I have is below:

  import csv 
     def IDSeg(elev):
      with open('path', mode='r') as infile:
      reader = csv.reader(infile)
      for rows in reader:
= rows[0]
= rows[1]
= {rows[0]:rows[1] for rows in reader}
       return lookUp.get(elev,0)