Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openpyxl find cell or row by value

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?

like image 561
Daniel Dow Avatar asked Sep 27 '22 14:09

Daniel Dow


1 Answers

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

like image 194
Charlie Clark Avatar answered Oct 12 '22 10:10

Charlie Clark