openpyxl按值查找单元格或行 [英] openpyxl find cell or row by value
本文介绍了openpyxl按值查找单元格或行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我除了遍历整个文档进行搜索以外还有其他值,是否有人知道在文档中可以找到单元格或行的方法?情况是,我必须比较非常大的电子表格,而我是通过使用每张纸的每条记录中存在的单个UUID来做到这一点的.
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.
所以,基本上:
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()
这似乎比需要的嵌套得多.有没有一种方法比这更容易在row2中查找值?
This seems more nested than it needs to be. Is there a way to find the value in rows2 easier than this?
推荐答案
不,除了逐个单元格外,没有其他按内容搜索的方式.
No, there is no other way of searching by content than going cell by cell.
这篇关于openpyxl按值查找单元格或行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文