<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: arcpy.da.searchcursor not accepting Excel as input in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053781#M60998</link>
    <description>&lt;P&gt;I am in the same boat as Dan, i.e., using Pro 2.8 beta (beta 1, not beta 2).&amp;nbsp; If I get a chance to test on a 2.7.x machine, I will let you know.&lt;/P&gt;</description>
    <pubDate>Mon, 03 May 2021 14:31:24 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2021-05-03T14:31:24Z</dc:date>
    <item>
      <title>arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053034#M60956</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;with arcpy.da.SearchCursor(r"C:\MASTER.xls\'Test$'", '*') as cursor:&lt;BR /&gt;RuntimeError: cannot open 'C:\MASTER.xls\'Test$''&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(r"C:\MASTER.xls\'Test$'", '*') as cursor:
	for row in cursor:
		print(row[0])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested a few things to eliminate any issues:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Moved the spreadsheet to different locations on different drives on my LAN. Same error each time&lt;/LI&gt;&lt;LI&gt;Changed the spreadsheet from xls to xlsx. Same error.&lt;/LI&gt;&lt;LI&gt;Set the spreadsheet as the workspace and tried iterating over the sheet. Same error.&lt;/LI&gt;&lt;LI&gt;Changed the UNC path to a map drive. Same error.&lt;/LI&gt;&lt;LI&gt;Tested on a feature class in a geodatabase. No issues. The code runs.&lt;/LI&gt;&lt;LI&gt;Tested again in Desktop 10.6. No issues. The code runs.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Is there any chance that ESRI has discontinued support for the cursor on spreadsheets or is there a different approach?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 01:53:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053034#M60956</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-04-30T01:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053044#M60958</link>
      <description>&lt;P&gt;Remove the single quotes from around the worksheet name.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 01:40:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053044#M60958</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-04-30T01:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053047#M60959</link>
      <description>&lt;P&gt;Unfortunately, that is not correct. The quotes are needed around the sheet name along with the $ at the end. It's needed for python to parse the path and understand that is a sheet within a excel instance. That being said, I did test and the same error occurs.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 01:44:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053047#M60959</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-04-30T01:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053051#M60961</link>
      <description>&lt;P&gt;Why not use Excel To Table and get a geodatabase table to simplify a lot of issues with excel files.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 01:47:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053051#M60961</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-30T01:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053054#M60962</link>
      <description>&lt;P&gt;Thanks Dan and good suggestion. The bigger code is quite involved so am hoping there's a simple answer to the original issue, but I just might test out to see if that workaround might be worthwhile.&lt;/P&gt;&lt;P&gt;I'm happy to see you're still perusing this forums. You've provided some good answers and suggestions to my own posts in the past, so thanks for that.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 01:51:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053054#M60962</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-04-30T01:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053058#M60964</link>
      <description>&lt;P&gt;No problem Mike.&amp;nbsp; I know esri has worked on dealing with excel files for a long time.&amp;nbsp; Because of its nature of allowing anything in any cell.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They have some pretty good advice in...&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/excel/work-with-excel-in-arcgis-pro.htm" target="_blank"&gt;Work with Microsoft Excel files in ArcGIS Pro—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;which covers a lot of issues.&amp;nbsp; I usually find it easier to avoid excel as much as possible unless I have to, but it often isn't the case, so strict formatting.&amp;nbsp; Some people prefer getting tabular data out into Pandas, but arcpy has some really handy numpy exchange functionality.&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 02:06:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053058#M60964</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-30T02:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053219#M60967</link>
      <description>&lt;P&gt;On my machine with Pro, I don't have or use quotes around my sheet names and everything works fine.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; # pass Excel worksheet with no quotes to search cursor
&amp;gt;&amp;gt;&amp;gt; with arcpy.da.SearchCursor(r"E:\tmp\sample.xlsx\Sheet1$", "*") as cur:
... for row in cur:
... print(row)
...
(10.0, 'g', 10.3, 1)
...
(22.0, 'i', -1.5, 11)
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; # pass Excel worksheet with single quotes to search cursor
&amp;gt;&amp;gt;&amp;gt; with arcpy.da.SearchCursor(r"E:\tmp\sample.xlsx\'Sheet1$'", "*") as cur:
... for row in cur:
... print(row)
...
Traceback (most recent call last):
File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
RuntimeError: cannot open 'E:\tmp\sample.xlsx\'Sheet1$''
&amp;gt;&amp;gt;&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 30 Apr 2021 15:18:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053219#M60967</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-04-30T15:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053247#M60969</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;...I usually find it easier to avoid excel as much as possible...&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;^^^^ THIS!^^^^^&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 16:01:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053247#M60969</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-04-30T16:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053448#M60971</link>
      <description>&lt;P&gt;That's interesting. That has never worked for me in either cursor on any ArcGIS Platform I've used over the years. When you navigate to the sheet using Catalog and look at the path in the address bar, it always have the single quotes around the sheet name.&lt;/P&gt;&lt;P&gt;Question. Which version of ArcGIS Pro are you running? We just updated to the latest version (2.7.3) python 3.7.9. I'm wondering if this is a bug introduced at the version I am running?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 21:30:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053448#M60971</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-04-30T21:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053452#M60972</link>
      <description>&lt;P&gt;Works in Pro 2.8 Beta 2&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

f = r"c:\Temp\Test28.xlsx\Test28$"

with arcpy.da.SearchCursor(f, '*') as cursor:
	for row in cursor:
		print(row[0])
        
b
c&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 30 Apr 2021 21:47:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053452#M60972</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-30T21:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053781#M60998</link>
      <description>&lt;P&gt;I am in the same boat as Dan, i.e., using Pro 2.8 beta (beta 1, not beta 2).&amp;nbsp; If I get a chance to test on a 2.7.x machine, I will let you know.&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 14:31:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053781#M60998</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-05-03T14:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053805#M61000</link>
      <description>&lt;P&gt;Ironically, I am in development of a script that does just this. I was working with ArcMap but just tested the search cursor on Excel in my ArcGIS Pro 2.7 environment and it works. No single quotes around the sheet name.&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 15:31:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1053805#M61000</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-05-03T15:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1054020#M61015</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I believe I solved my issue. After taking some of your suggestions to remove the single quotes around the sheet name, I tried something else. In my case, my actual sheet name had 3 words in it, separated by spaces (something like: &lt;STRONG&gt;my sheet name$&lt;/STRONG&gt;). I decided to test to see if the spaces were causing the issues and it appears that it did. I replaced the spaces with underscore, removed the single quotes and my final path looked something like:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;r"C:\MASTER.xls\My_Sheet_Name$"&lt;/LI-CODE&gt;&lt;P&gt;and that worked. As mentioned, I had no issue using my previous path (with white spaces and single quotes) in any of Desktop 10.x, so this appears to be introduced somewhere with Pro.&lt;/P&gt;&lt;P&gt;Hope that helps someone else having the same issue.&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 22:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1054020#M61015</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-05-03T22:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.searchcursor not accepting Excel as input</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1054029#M61016</link>
      <description>&lt;P&gt;That is because the Excel to Table tool does it for you&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/excel/work-with-excel-in-arcgis-pro.htm" target="_blank"&gt;Work with Microsoft Excel files in ArcGIS Pro—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For example, a sheet called Year to Date in Excel will display in the Catalog or Contents pane as 'Year to Date$', placing the name in quotes since it contains spaces. When used in a geoprocessing tool, the underlying table is used directly, so you may notice a slight change in the name. Using the same example, if you drag the Excel sheet Year to Date into a geoprocessing tool, or select it from an input drop-down menu, it will be represented as T_Year_to_Date$_.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Spaces are basically not recommended for paths, names , basically anything. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 22:50:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-searchcursor-not-accepting-excel-as-input/m-p/1054029#M61016</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-05-03T22:50:27Z</dc:date>
    </item>
  </channel>
</rss>

