<?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 pd.read_excel gets error when script tool runs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265317#M67023</link>
    <description>&lt;P&gt;Hello people,&lt;/P&gt;&lt;P&gt;I cam across an error,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;AttributeError: ValueObject: Get attribute __class__ does not exist&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;when I run the script tool, I will get the error for the line,&amp;nbsp;"df = pd.read_excel(spreadsheet)"&lt;/P&gt;&lt;P&gt;This simple code to read the spreadsheet has not problem in Python IDE but it will fail with the error in script tool.&lt;/P&gt;&lt;P&gt;As I have not figure out the error message, any advice is much appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2023 02:08:09 GMT</pubDate>
    <dc:creator>Aнастасия88</dc:creator>
    <dc:date>2023-03-08T02:08:09Z</dc:date>
    <item>
      <title>pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265317#M67023</link>
      <description>&lt;P&gt;Hello people,&lt;/P&gt;&lt;P&gt;I cam across an error,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;AttributeError: ValueObject: Get attribute __class__ does not exist&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;when I run the script tool, I will get the error for the line,&amp;nbsp;"df = pd.read_excel(spreadsheet)"&lt;/P&gt;&lt;P&gt;This simple code to read the spreadsheet has not problem in Python IDE but it will fail with the error in script tool.&lt;/P&gt;&lt;P&gt;As I have not figure out the error message, any advice is much appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 02:08:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265317#M67023</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2023-03-08T02:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265333#M67024</link>
      <description>&lt;P&gt;Have you specified the full path to "spreadsheet".&lt;/P&gt;&lt;P&gt;perhaps the script tool hasn't specified the workspace/folder where it is&amp;nbsp; to be found&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 03:20:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265333#M67024</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-08T03:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265336#M67026</link>
      <description>&lt;P&gt;Thanks for our reply!&lt;/P&gt;&lt;P&gt;I am having this problem when running script tool on ArcGIS Pro. The full path is to be defined via the tool with parameter setting as below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A0328_0-1678246462790.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64658i6EAA18929C8C6785/image-size/medium?v=v2&amp;amp;px=400" role="button" title="A0328_0-1678246462790.png" alt="A0328_0-1678246462790.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And the code for the script tool is simple as below.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pandas as pd
import arcpy

def ScriptTool(spreadsheet):
    arcpy.AddMessage('Start')
    df = pd.read_excel(spreadsheet)
    name_values = df["Name"].unique()
    query = "Name IN {}".format(tuple(name_values))
    arcpy.AddMessage(query)

if __name__ == '__main__':
    spreadsheet = arcpy.GetParameter(0)
    ScriptTool(spreadsheet)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 03:36:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265336#M67026</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2023-03-08T03:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265341#M67028</link>
      <description>&lt;P&gt;I'm new to Arcpy, b&lt;SPAN&gt;ut from scripting point of view, I can suggest you to put a print statement after this line&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    spreadsheet = arcpy.GetParameter(0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;to print(spreadsheet) and double check what you are passing to pandas.read_excel(). This should be either a str or path object, maybe arcpy.GetParameter(0) is not returning what you expect.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 04:58:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265341#M67028</guid>
      <dc:creator>Mahdi_Ch</dc:creator>
      <dc:date>2023-03-08T04:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265365#M67029</link>
      <description>&lt;P&gt;if you are providing the path, did you try&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spreadsheet = arcpy.GetParameterAsText(0)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Mar 2023 09:36:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265365#M67029</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-08T09:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265756#M67040</link>
      <description>&lt;P&gt;Thanks Mahgi_Ch for your reply!&lt;/P&gt;&lt;P&gt;It was a just my careless mistake in the code.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 21:28:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265756#M67040</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2023-03-08T21:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265758#M67041</link>
      <description>&lt;P&gt;Thanks Dan for pointing out!&lt;/P&gt;&lt;P&gt;That was my careless mistake, I excluded AsText somehow - it works now.&lt;/P&gt;&lt;P&gt;Apart from that, I have a question. A code using GetParameter(0) works in both Python window and Python IDE. But this does not work it the code is embedded in a Script tool. Do you know why this occurs?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 21:34:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265758#M67041</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2023-03-08T21:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265803#M67043</link>
      <description>&lt;P&gt;I am not sure, I use custom toolboxes rather than python toolboxes, so I can specify my parameter types there and I always use GetParameterAsText and let arcpy's behind the scenes handle any stuff from arcobjects conversions&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 22:48:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265803#M67043</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-08T22:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: pd.read_excel gets error when script tool runs</title>
      <link>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265828#M67044</link>
      <description>&lt;P&gt;I see, thanks Dan!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 23:48:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pd-read-excel-gets-error-when-script-tool-runs/m-p/1265828#M67044</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2023-03-08T23:48:54Z</dc:date>
    </item>
  </channel>
</rss>

