P
patrick.waldo
Hi all,
I am trying to figure out a way to read colors with xlrd, but I did
not understand the formatting.py module. Basically, I want to sort
rows that are red or green. My initial attempt discovered thattext:u'test1.txt' (XF:22)
text:u'test2.txt' (XF:15)
text:u'test3.txt' (XF:15)
text:u'test4.txt' (XF:15)
text:u'test5.txt' (XF:23)
So, I thought that XF:22 represented my red highlighted row and XF:23
represented my green highlighted row. However, that was not always
true. If one row is blank and I only highlighted one row, I got:text:u'test1.txt' (XF:22)
text:u'test2.txt' (XF:22)
text:u'test3.txt' (XF:22)
text:u'test4.txt' (XF:22)
text:u'test5.txt' (XF:22)
empty:'' (XF:15)
text:u'test6.txt' (XF:22)
text:u'test7.txt' (XF:23)
Now NoFill is XF:22! I am sure I am going about this the wrong way,
but I just want to store filenames into a dictionary based on whether
they are red or green. Any ideas would be much appreciated. My code
is below.
Best,
Patrick
filenames = {}
filenames.setdefault('GREEN',[])
filenames.setdefault('RED',[])
book = xlrd.open_workbook("/home/pwaldo2/work/workbench/
Summary.xls",formatting_info=True)
SumDoc = book.sheet_by_index(0)
n=1
while n<SumDoc.nrows:
cell = SumDoc.cell(n,5)
print cell
filename = str(cell)[7:-9]
color = str(cell)[-3:-1]
if color == '22':
filenames['RED'].append(filename)
n+=1
elif color == '23':
filenames['GREEN'].append(filename)
n+=1
I am trying to figure out a way to read colors with xlrd, but I did
not understand the formatting.py module. Basically, I want to sort
rows that are red or green. My initial attempt discovered thattext:u'test1.txt' (XF:22)
text:u'test2.txt' (XF:15)
text:u'test3.txt' (XF:15)
text:u'test4.txt' (XF:15)
text:u'test5.txt' (XF:23)
So, I thought that XF:22 represented my red highlighted row and XF:23
represented my green highlighted row. However, that was not always
true. If one row is blank and I only highlighted one row, I got:text:u'test1.txt' (XF:22)
text:u'test2.txt' (XF:22)
text:u'test3.txt' (XF:22)
text:u'test4.txt' (XF:22)
text:u'test5.txt' (XF:22)
empty:'' (XF:15)
text:u'test6.txt' (XF:22)
text:u'test7.txt' (XF:23)
Now NoFill is XF:22! I am sure I am going about this the wrong way,
but I just want to store filenames into a dictionary based on whether
they are red or green. Any ideas would be much appreciated. My code
is below.
Best,
Patrick
filenames = {}
filenames.setdefault('GREEN',[])
filenames.setdefault('RED',[])
book = xlrd.open_workbook("/home/pwaldo2/work/workbench/
Summary.xls",formatting_info=True)
SumDoc = book.sheet_by_index(0)
n=1
while n<SumDoc.nrows:
cell = SumDoc.cell(n,5)
print cell
filename = str(cell)[7:-9]
color = str(cell)[-3:-1]
if color == '22':
filenames['RED'].append(filename)
n+=1
elif color == '23':
filenames['GREEN'].append(filename)
n+=1