xxxxxxxxxx
import pandas as pd
### Way 1
# Load excel file
data = pd.ExcelFile('filename.xlsx')
# See sheet names
print(data.sheet_names)
# Loading sheet
df1 = data.parse('sheetname') # sheet name
df2 = data.parse(0) # sheet index
### Way 2
df = pd.read_excel('filename.xlsx', sheet_name='sheetname')
xxxxxxxxxx
df = pd.read_excel('Path.xlsx', sheet_name='Desired Sheet Name', na_values='n/a')
xxxxxxxxxx
import pandas as pd
df = pd.read_excel (r'Path where the Excel file is stored\File name.xlsx')
print (df)
xxxxxxxxxx
import pandas as pd
# Specify the file path of the Excel file
excel_file = "path/to/your/file.xlsx"
# Read the Excel file and store it in a DataFrame
df = pd.read_excel(excel_file)
# Print the contents of the DataFrame
print(df)
xxxxxxxxxx
import pandas as pd
df = pd.read_excel(r'Path where the Excel file is stored\File name.xlsx',
sheet_name='your Excel sheet name')
print(df)
xxxxxxxxxx
#!/usr/bin/env python
from openpyxl import Workbook
import time
book = Workbook()
sheet = book.active
sheet['A1'] = 56
sheet['A2'] = 43
now = time.strftime("%x")
sheet['A3'] = now
book.save("sample.xlsx")
xxxxxxxxxx
#Creating the ExcelFile object
xls = pd.ExcelFile(r'Path.xlsx')
#In the next step, you can pass the ExcelFile object to read_excel to import
#its content, instead of the path to the file.
data = pd.read_excel(xls, sheet_name='Name_of_sheet', index_col='Index_Column')
xxxxxxxxxx
import pandas as pd
df = pd.read_excel("sample.xlsx")
print(df)
xxxxxxxxxx
conda install -c anaconda xlrd
#libarary that reads excel file
df = pd.read_excel (r'Path where the Excel file is stored\File name.xlsx', sheet_name='your Excel sheet name')