简体   繁体   中英

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?

不,除了逐个单元格之外,没有其他内容搜索方式。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM