0

I've got multiple excels and I need a specific value but in each excel, the cell with the value changes position slightly. However, this value is always preceded by a generic description of it which remains constant in all excels.

I was wondering if there was a way to ask Python to grab the value to the right of the element containing the string "xxx".

Dima Chubarov
  • 16,199
  • 6
  • 40
  • 76
Lucas
  • 1
  • 1
  • 1
    Maybe this will help you? https://stackoverflow.com/questions/26640129/search-for-string-in-all-pandas-dataframe-columns-and-filter – 3dSpatialUser Dec 07 '22 at 12:53

1 Answers1

1

try iterating over the excel files (I guess you loaded each as a separate pandas object?) somehting like for df in [dataframe1, dataframe2...dataframeN].

Then you could pick the column you need (if the column stays constant), e.g. - df['columnX'] and find which index it has: df.index[df['columnX']=="xxx"]. Maybe will make sense to add .tolist() at the end, so that if "xxx" is a value that repeats more than once, you get all occurances in alist.

The last step would be too take the index+1 to get the value you want.

Hope it was helpful. In general I would highly suggest to be more specific in your questions and provide code / examples.

ArieAI
  • 354
  • 1
  • 12