| 1 |
---- Here Sam received a set of HUGE spreadsheets that looks to be a file report. They highlighted what they wanted deleted, so we needed to
|
| 2 |
export the highlighted rows. I just created two (or more) txt files with color 1 and then No Color, etc.---
|
| 3 |
>>> xlApp = Dispatch('Excel.Application')
|
| 4 |
>>> xlBook = xlApp.Workbooks.Open(r'C:\Test-PY\FILES TO DELETE_FCOMP001 Direcotry List.xlsx')
|
| 5 |
>>> ws = xlBook.Worksheets("FCOMP001 Direcotry List")
|
| 6 |
>>> col = ws.Range("G1:G222257")
|
| 7 |
>>> for cell in col:
|
| 8 |
... if cell.Interior.Color in colorMatrix.keys():
|
| 9 |
... colorMatrix[cell.Interior.Color].append(cell.Value)
|
| 10 |
... else:
|
| 11 |
... colorMatrix[cell.Interior.Color] = [cell.Value,]
|
| 12 |
...
|
| 13 |
>>> len(colorMatrix.keys())
|
| 14 |
2
|
| 15 |
>>> colorMatrix.keys()
|
| 16 |
[65535.0, 16777215.0]
|
| 17 |
>>> color1 = colorMatrix[65535]
|
| 18 |
>>> color1.sort()
|
| 19 |
>>> outputFile = open(r"C:\Test-PY\FILES TO DELETE_FCOMP001 Direcotry List COLOR.txt",'w')
|
| 20 |
>>> for i in color1:
|
| 21 |
... outputFile.write(i.encode('utf8') + "\n".encode('utf8'))
|
| 22 |
...
|
| 23 |
>>> outputFile.close()
|
| 24 |
>>> outputFile = open(r"C:\Test-PY\FILES TO DELETE_FCOMP001 Direcotry List NO-COLOR.txt",'w')
|
| 25 |
>>> color3 = colorMatrix[16777215]
|
| 26 |
>>> color3.sort()
|
| 27 |
>>> for i in color3:
|
| 28 |
... outputFile.write(i.encode('utf8') + "\n".encode('utf8'))
|
| 29 |
...
|
| 30 |
>>> outputFile.close()
|
| 31 |
>>>
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
-------- END ------- |