openpyxl find cell or row by value

7.9k views Asked by At

Is there a method anyone knows of where I can find a cell or row in a document if I have a value other than iterating through the whole document to search for it? Case is, I have to very large spread sheets that I need to compare and I am doing that by using a single UUID that exists in each record in each sheet.

So, basically:

ws1 = rows1
ws2 = rows2  
for row1 in rows1:
    uuid = row1[0].value
    comp = row1[1].value
        for row2 in rows2:
            if row2[0] = uuid
                if row2[0] = comp
                    do-stuff()

This seems more nested than it needs to be. Is there a way to find the value in rows2 easier than this?

1

There are 1 answers

0
Charlie Clark On BEST ANSWER

No, there is no other way of searching by content than going cell by cell.