Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pd read excel()_ errors
#1
Hi,

I am trying to run a simple pd.read_excel() function to read an excel file,"weather_data" I saved on my Mac in a python folder using the following code:


df = pd.read_excel(':C/Macintosh HD Users/myusername/python/weather_data.xlsx')

and I get the following error:

/Users/myusername/python)
^
SyntaxError: invalid syntax

Does anyone have any help or thoughts on best practices, or syntax tips?

Sincere thanks,
me
Reply
#2
(Jul-17-2020, 10:38 PM)fat_fingers_squared Wrote: df = pd.read_excel(':C/Macintosh HD Users/myusername/python/weather_data.xlsx')
Path should be like this.
df = pd.read_excel('C:/Macintosh HD Users/myusername/python/weather_data.xlsx')
Reply
#3
(Jul-17-2020, 11:46 PM)snippsat Wrote:
(Jul-17-2020, 10:38 PM)fat_fingers_squared Wrote: df = pd.read_excel(':C/Macintosh HD Users/myusername/python/weather_data.xlsx')
Path should be like this.
df = pd.read_excel('C:/Macintosh HD Users/myusername/python/weather_data.xlsx')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to access excel file on our sharepoint server but getting errors cubangt 0 805 Feb-16-2023, 08:11 PM
Last Post: cubangt
  how to read txt file, and write into excel with multiply sheet jacklee26 14 9,899 Jan-21-2023, 06:57 AM
Last Post: jacklee26
  How do I read in a Formula in Excel and convert it to do the computation in Python? JaneTan 2 2,634 Jul-07-2021, 02:06 PM
Last Post: Marbelous
  Read and write active Excel file euras 4 3,482 Jun-29-2021, 11:16 PM
Last Post: Pedroski55
  code to read files in folders and transfer the file name, type, date created to excel Divya577 0 1,855 Dec-06-2020, 04:14 PM
Last Post: Divya577
  Read excel file to determine the rules abc12345 4 2,666 May-13-2020, 12:59 PM
Last Post: abc12345
  iterate read data from excel sheet jp2017 1 2,322 Jun-19-2019, 07:45 PM
Last Post: micseydel
  Read data and save in excel parthi1705 0 2,409 Apr-09-2018, 09:37 AM
Last Post: parthi1705
  Strings read from excel don't work? Tibas 0 2,402 Mar-06-2018, 10:37 PM
Last Post: Tibas
  I can write to but cannot read from Excel using python. Emerogork 2 2,709 Feb-13-2018, 08:27 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020