ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Redgrave/EndoIGChgReqSysToServer.py
Revision: 790
Committed: Tue Sep 13 14:07:38 2022 UTC (3 years, 6 months ago) by nino.borges
Content type: text/x-python
File size: 3380 byte(s)
Log Message:
edited to be able to use this file to test the auxilium top level files.  will need to edit this to use the different sources, like going back to service now.

File Contents

# User Rev Content
1 nino.borges 780 """
2    
3     EndoIGChgReqSysToServer
4    
5     Created by:
6     Emanuel Borges
7     08.04.2022
8    
9     Using COM, this program will create a simplified txt file with rows from the Change Request Exports spreadsheets that hit on our server names. I'll then ingest this
10     on the main EndoIGServerAnalyzer program.
11    
12     """
13    
14     from win32com.client import Dispatch
15    
16     if __name__ == '__main__':
17 nino.borges 790 outputFileName = r"C:\Test_Dir\serverToExcel-Aux-SRAS.txt"
18 nino.borges 780
19 nino.borges 788 #xlSpreadSheetFileName = r"C:\Users\eborges\Documents\Cases\Endo\20220715 - IG Projects\4 - Develop Identification Process to Inventory NCDS stored in Endo IT\_fromEndo\_otherInformation\ServiceNow Change Requests Jan 30 2020 to July 28 2022 - Copy.xlsx"
20 nino.borges 790 #xlSpreadSheetFileName = r"C:\Users\eborges\Documents\Cases\Endo\20220715 - IG Projects\4 - Develop Identification Process to Inventory NCDS stored in Endo IT\_fromEndo\_otherInformation\Legacy SNOW Change Request data dump Dec 2007 to Jan 2020.xlsx"
21     xlSpreadSheetFileName = r"C:\Test_Dir\Auxilium System Retirement and Archival Signoff.xlsx"
22     #win2kServersFile = r"C:\Users\eborges\Documents\Cases\Endo\20220715 - IG Projects\4 - Develop Identification Process to Inventory NCDS stored in Endo IT\_fromEndo\_csv\Win8Servers_NOFilter.csv"
23     win2kServersFile = r"C:\Users\eborges\Documents\Cases\Endo\20220715 - IG Projects\4 - Develop Identification Process to Inventory NCDS stored in Endo IT\_fromEndo\_csv\Test.csv"
24 nino.borges 780
25     serverNamesMatrix = {}
26     contents = open(win2kServersFile).readlines()
27     contents = contents[1:]
28     for line in contents:
29     line = line.replace("\n","")
30     line = line.split("|")
31     serverNamesMatrix[line[0].upper()] = 1
32    
33     print("There are %s unique server names."%len(list(serverNamesMatrix.keys())))
34     outputFile = open(outputFileName,'w')
35    
36     xlApp = Dispatch('Excel.Application')
37     xlBook = xlApp.Workbooks.Open(xlSpreadSheetFileName)
38     sht = xlBook.Worksheets(1)
39     for serverName in list(serverNamesMatrix.keys()):
40     print("Now processing %s..."% serverName)
41 nino.borges 783 #outputFile.write(serverName + "|")
42 nino.borges 780 findAllResultsList = []
43     foundLoc = sht.UsedRange.Cells.Find(serverName)
44 nino.borges 783 if foundLoc:
45     while (foundLoc.Row,foundLoc.Column) not in findAllResultsList:
46     findAllResultsList.append((foundLoc.Row,foundLoc.Column))
47     foundLoc = sht.UsedRange.Cells.FindNext(foundLoc)
48     uniqueRows = set()
49     for rowNumb, colNumb in findAllResultsList:
50     uniqueRows.add(rowNumb)
51     uniqueRows = list(uniqueRows)
52     uniqueRows.sort()
53     for uniqueRowNumb in uniqueRows:
54 nino.borges 788 #outputFile.write("%s|%s|%s|%s|%s|%s\n"%(serverName,sht.Cells(uniqueRowNumb,1).value, sht.Cells(uniqueRowNumb,2).value, sht.Cells(uniqueRowNumb,12).value, sht.Cells(uniqueRowNumb,36).value, sht.Cells(uniqueRowNumb,114).value))
55 nino.borges 790 #outputFile.write("%s|%s|%s\n"%(serverName,sht.Cells(uniqueRowNumb,2).value, sht.Cells(uniqueRowNumb,3).value))
56     outputFile.write("%s|%s|%s\n"%(serverName,sht.Cells(uniqueRowNumb,1).value, sht.Cells(uniqueRowNumb,6).value))
57 nino.borges 783 else:
58 nino.borges 788 #outputFile.write(serverName + "|||||\n")
59     outputFile.write(serverName + "||\n")
60 nino.borges 783 #outputFile.write("\n")
61 nino.borges 780 outputFile.close()
62     xlBook.Close()
63