Okay, so basically I'm trying to search all the values in a column in an excel file and then mark them green if they match any of the data values in a separate text file.
Sorry if my code is hard to read, but still very new to it.
So, the following will work fine and print the dictIPExcel dictionary without any problems:
dictIPExcel = {}
wb = openpyxl.load_workbook('file.xlsx')
sheet = wb.active
greenFill = PatternFill(start_color='0000B200', end_color='0000B200', fill_type='solid')
IPlist = open('No Config or Denied devices.txt').read().split('\n')
for t in range(19,100):
dictIPExcel["A{0}".format(t)] = sheet['A'+ str(t)].value
print dictIPExcel
sheetz = wb.sheetnames
for a in sheetz:
sheet = a
dictIPExcel = {}
for l in range(19,100):
for x,y in dictIPExcel.items():
for z in IPlist:
if y == z:
print "match"
sheet[x].fill = greenFill
wb.save('textCopy4.xlsx')
, "dictIPExcel" , "TypeError: ". , , , , "A50", , . , ? , . :
for a in sheetz:
sheet = a
dictIPExcel = {}
for t in range(19,100):
dictIPExcel["A{0}".format(t)] = sheet['A'+ str(t)].value
for l in range(19,100):
for x,y in dictIPExcel.items():
for z in IPlist:
if y == z:
print "match"
sheet[x].fill = greenFill
:
Traceback (most recent call last):
File "C:..\testing.py", line 49, in <module>
dictIPExcel["A{0}".format(t)] = sheet['A'+ str(t)].value
TypeError: string indices must be integers
-, , ? , , , , ?