Python Forum

Full Version: Match string return different cell string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Is there a way to search for a string, and once it's found return the value thats 9 cells below it?

This code reads in TFile only column B data. Then it reads in TDetail looks at cell A1 shortens the word, and then makes it a string example AA1150. Then I want to search for TDetail (example AA1150) inside TFile, and once that string is located return the value that is 9 cells below it.

TFile = Row B tons of data TDetail= string example AA1150

Search TTFile for TTDetail once found return value 9 cells below it.

TFile=pd.read_excel(TF, usecols="B")
  
TDetail=pd.read_excel(input_file, usecols="A",nrows=1,header=None,squeeze=True).str.slice(start=28,stop=-2).to_string(index=False).strip()

result=TFile['Name'].str.contains(TDetail)