So i have a problem, that i need to get the cell's coordinates (in google-sheets) by it's content, for example a have a cell that has "hello" in it's self, and a have some amount of other cell's. For example "world" and i know that "hello" is in column 4 (there is only 1 hello in the example), how do i get it's coordinates on python 3, please help! here is how it lookes like in google-sheets : .
Please give me a code that will make this in my understanding:
if "hello" in sheet.col_values(4):
print(coordinates of "hello")
How I approached your question:
import pandas as pd df = pd.read_csv('path/to/file', header=None) #if your file is .csv df = pd.read_excel('path/to/file', header=None) #if your file is .xlsx
Python lists are 0-based. So if I want an element that is located in my dataframe at 7th row /4th column, I will be able to get it like this:
df.iloc[6, 3]
for i in range(0, len(df)): if df.iloc[i, 3] == 'hello': print(i, 3)