Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to create a Python array using data from an ArcGIS attribute table. Here's the code I've written so far:

import arcpy
import numpy
input = "c:/data/from/arcgis"
arr = arcpy.da.TabletoNumPyArray(input,('OBJECTID','SoilEvap5'))
a = arr["OBJECTID"]
b = arr["SoilEvap5"]
np.columnstack((a,b))
print arr

When I try running this in the ArcGIS Python window, it returns:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 7, in <module>
AttributeError: 'module' object has no attribute 'TabletoNumPyArray'

Why is this error showing up and how can I fix it?

share|improve this question
    
What is it you're trying to do here? I can't see any arcpy commands (except import arcpy). What line gives you there error? –  Michael Miles-Stimson Jul 20 at 22:10
    
This is a very common error message: gis.stackexchange.com/… –  PolyGeo Jul 20 at 22:32
    
A good editor will help you avoid this sort of problem. I use PyWin which has some basic InteliSense (you type in arcpy.da. and all the methods available appear)... saves typing and avoids mistyping/incorrect case. Other editors no doubt can do this and IMO it's worth finding a good one. –  Michael Miles-Stimson Jul 20 at 22:50
    
I am still happy to just work with IDLE as my Python editor because it also has code completion ("IntelliSense") - stackoverflow.com/a/16467896/820534 - but to see that you need to put import arcpy and run your code once first. Also, to force it to auto complete using Ctrl-spacebar is a trick worth knowing. –  PolyGeo Jul 20 at 22:55

1 Answer 1

up vote 5 down vote accepted

The correct name for this function is TableToNumPyArray (arcpy.da) i.e. there should be a capital "T" on "to".

Correct capitalization is very important to the Python programming language.

share|improve this answer
    
should the field names be a tuple ('OBJECTID','SoilEvap5') or list ['OBJECTID','SoilEvap5'] or doesn't that matter in this case? Where tools say [field_names,...] I have interpreted that as a list but it wouldn't surprise me if a tuple could be substituted. –  Michael Miles-Stimson Jul 20 at 22:47
1  
@MichaelMiles-Stimson I think lists and tuples are interchangeable within at least some (perhaps all) ArcPy functions but I've not tested to say with 100% confidence. –  PolyGeo Jul 20 at 22:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.