Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read excel sheet data in python

How to read excel file in python I already used some program but not work.I used that method given below in image

And the errors in that image

I want to create folder folder of separate sets This is a excel sheet

I want to create sets folder inside 3D folder given below in image

like image 510
Saurabh Sharma Avatar asked Jan 27 '26 04:01

Saurabh Sharma


1 Answers

I hope, it helps you in understanding how to read excel file, try to correctly specify your file path. In my case ./ means current file where my python file exist. Move your excel file where your python file exist

Install:

pip install pandas openpyxl

Solution 1

import pandas as pd
df = pd.read_excel('./TfidfVectorizer_sklearn.xlsx')
df

Solution 2

import openpyxl

book = openpyxl.load_workbook('./TfidfVectorizer_sklearn.xlsx')

sheet = book.active
cells = sheet['A1': 'D5']

for c1, c2, c3, c4 in cells:
    print(f"{c1.value} {c2.value} {c3.value} {c4.value}")
like image 147
Muhammad Ali Avatar answered Jan 28 '26 16:01

Muhammad Ali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!