Akhil Reddy
Akhil Reddy

Reputation: 391

Reading xlsx file using jupyter notebook

I have tried to read an xlsx file which is stored in my system using jupyter notebook.I had run the jupyter notebook from the present directory where my file is present.But it is showing an error as "module not found error".

This is the image of the code i have written and also the error i got

This is the complete traceback

Upvotes: 4

Views: 74789

Answers (4)

Hemanth Kocherlakota
Hemanth Kocherlakota

Reputation: 56

The below code should able to access /read your excel file

import pandas as pd
path = ('...\\filename.xlsx')
xl = pd.ExcelFile(path)
print(xl.sheet_names)

The above command shows the sheets in a xlsx file

df1 = xl.parse('Sheet1')

Above command parses the sheet required

Upvotes: 4

Jonathan Um
Jonathan Um

Reputation: 1

import pandas as pd
df = pd.read_excel('file_name.xlsx', 'Sheet1')
df

*you must import your .xlsx file into the Jupyter notebook file... *you may also import it into a Github repository and get the raw file then just copy and paste it into where it says 'file_name.xlsx'

[raw file URL example][1]

Upvotes: 0

Marcell Kovacs
Marcell Kovacs

Reputation: 21

Same outout, but this one worked for me.

import pandas as pd

df = pd.read_excel (r'C:\Users\(NAME)\Desktop\(FILENAME).xlsx')
print (df)

Upvotes: 2

ARVIND CHAUHAN
ARVIND CHAUHAN

Reputation: 55

import pandas as pd
wb = pd.ExcelFile('D:\\<Excel File Name>.xlsx')
ds = wb.parse('<Sheet  Name>')
print(ds)

Upvotes: -1

Related Questions