Hello all,
I have had a script for a number of years that has always worked in python 2/ArcGIS Desktop and I have decided to bring it into the python 3/ArcGIS Pro environment. As part of the script, I use the arcpy.da.SearchCursor function to read an excel file. This has always worked in the Desktop environment, yet I am getting the following error:
with arcpy.da.SearchCursor(r"C:\MASTER.xls\'Test$'", '*') as cursor:
RuntimeError: cannot open 'C:\MASTER.xls\'Test$''
My code is:
with arcpy.da.SearchCursor(r"C:\MASTER.xls\'Test$'", '*') as cursor:
for row in cursor:
print(row[0])
I tested a few things to eliminate any issues:
- Moved the spreadsheet to different locations on different drives on my LAN. Same error each time
- Changed the spreadsheet from xls to xlsx. Same error.
- Set the spreadsheet as the workspace and tried iterating over the sheet. Same error.
- Changed the UNC path to a map drive. Same error.
- Tested on a feature class in a geodatabase. No issues. The code runs.
- Tested again in Desktop 10.6. No issues. The code runs.
Is there any chance that ESRI has discontinued support for the cursor on spreadsheets or is there a different approach?