Hi I'm just learning the function of SearchCursor
this is my code here
import arcpy points = r'D:\GIS\turto\pop.shp' with arcpy.da.SearchCursor(points,['iso_a2', 'adm0_a3']) as citycursor: for x in citycursor: print(x[0]); and the error just show: D:\Users\Jay\PycharmProjects\learn\venv\Scripts\python.exe D:/Users/Jay/PycharmProjects/learn/search.py Traceback (most recent call last): File "D:/Users/Jay/PycharmProjects/learn/search.py", line 10, in <module> with arcpy.da.SearchCursor(points,['iso_a2', 'adm0_a3']) as citycursor: TypeError: object() takes no parameters Process finished with exit code 1
I followed the tutorial of this one
6 - Search Cursors - Arcgis Scrpting with Python - YouTube
and I checked the syntax and other examples, all didnt help
I wonder what I do wrong
Please help me, thank you
Please remove the ; at the end of the print statement. I tested a search cursor on your dataset without any errors. What python version are you using? Can you import arcpy from the interactive python IDE environment without errors?
semi-colon is ok in python 3 at least
a = [1,2,3,4]
for i in a:
print(i);
1
2
3
4
Hi, I can use other arcpy funtions such as search by location, so it means the arcpy in pycharm is imported correctly, right?
I'm using the python 2.7 which came with ArcGIS 10.5
I was wondering what was missing
can the shapefile be viewed in ArcMap and can you confirm that the fields are indeed there
yes, I just downloaded from the Nature Earth website for the tutorial. And as Mitch tested, the data is fine.