P
P
PerviiNikitos2022-02-13 21:05:32
Python
PerviiNikitos, 2022-02-13 21:05:32

How to check an Excel table in Python, if the given value is in the table - display the entire row?

Let's say I enter a value in the python

name = input ()

I need the python to check the cells of the 1st column, if there is a name in this column, it displays the entire line.
Here is an excel file 'baza' as an example, it has a table with fighters)

620948513126a818165631.jpeg

Let's say I want to check Anton's history, I enter 'anton', from python I want to get such a verified list:

anton green not rivers Morgunov 02.12.2020
anton red rather rivers Safonova 12.12.2020
anton green is strong Ivanov 12.15.2020
anton yellow rather Ivanov rivers 12.19.2020

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PavelMos, 2022-02-14
@PerviiNikitos

it's easier to import Excel into a dataframe through pandas than to open it through some Python Excel module and work with columns, cells

df1=pandas.read_excel(путь, header=0)
print (df1.loc[df1['Боец']=='антон'])

and if you need a two-dimensional array, then
List=df1.to_numpy().tolist()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question