我正在使用Excel工作表进行迁移准备。我有一个工作簿/工作表,其中包含Netscalers(MAS)上存在的所有网络服务器IP。我需要获取Migration_prep工作簿/工作表中列出的一列IP,并通过MAS表中的IP进行循环,并进行任何匹配并将它们放入另一个工作簿中。 我可以使用文本文件做到这些,但我希望只保留所有数据在Excel表格中。我已经阅读了“使用Python自动化枯燥的东西”一书,但它并没有教会如何做到这一点。我已经搜索谷歌和这里的答案,但没有甚至接近。Python脚本需要一列IP,在另一个工作簿中搜索匹配的匹配项,将匹配项放在另一个工作簿中。
import openpyxl
import xlrd
import xlwt
wb1 = openpyxl.load_workbook('LB_migration.xlsx')
ws1 = wb1.get_sheet_by_name('Servers')
#IP should be placed in Column 'J2' and continue down for as much as needd.
wb2 = openpyxl.load_workbook('ME06.xlsx')
ws2 = wb2.get_sheet_by_name('Dependency_Details')
#Migration server IPs are listed in Column P starting with row 2.
wb3 = openpyxl.load_workbook('MAS.xlsx')
ws3 = wb3.get_sheet_by_name('massheet')
#All servers listed in Netscaler configs are in column C starting in row 2
#This should be the list that is parsed with the Migration server IPs
ws1.iter_rows('A1:A235')
如果你阅读循环和openpyxl的章节,你会发现它实际上给你提供了你需要的一切。 – toonarmycaptain
我通过两遍阅读该章节,然后走出了Python循环课程,获取了Python Crash Course。谢谢 –
请提供一个比较和改变的例子。 –