ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Redgrave/Amazon_ConsilioToFullNamesOveride.py
Revision: 843
Committed: Fri Dec 6 21:48:19 2024 UTC (15 months, 2 weeks ago) by nino.borges
Content type: text/x-python
File size: 2089 byte(s)
Log Message:
This program will take a spreadsheet, supplied by Consilio, of the formatted names to email addresses table that they use and create a FullNamesOveride file.
The columns are normally Raw Entry	Formatted Name	Priv Entity Email Address
Assumes the top row is the header row, which is skips.

File Contents

# Content
1 """
2
3 Amazon_ConsilioToFullNamesOveride
4
5 Created by:
6 Emanuel Borges
7 12.5.2024
8
9 This program will take a spreadsheet, supplied by Consilio, of the formatted names to email addresses table that they use and create a FullNamesOveride file.
10 The columns are normally Raw Entry Formatted Name Priv Entity Email Address
11 Assumes the top row is the header row, which is skips.
12
13 """
14
15
16 import os
17 from win32com.client import Dispatch
18
19
20 if __name__ == '__main__':
21 consilioFileName = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\Consilio\VEAS-MasterAttorneyList\2024.12.05 - H95472_Amazon VEAS_EmailsInfoForAsterisks.xlsx"
22 fullNamesOverideFileName = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\Consilio\VEAS-MasterAttorneyList\FullNameOverides.txt"
23
24
25 outputFile = open(fullNamesOverideFileName,'w')
26 emailAddressMatrix = {}
27
28 xlApp = Dispatch('Excel.Application')
29 xlBook = xlApp.Workbooks.Open(consilioFileName)
30 sht = xlBook.Worksheets(1)
31
32 ## find the bottom row
33 bottom = 0
34 while sht.Cells(bottom + 1, 1).Value not in [None, '']:
35 bottom = bottom +1
36 #print(f"first value is {sht.Cells(2, 1).Value}")
37 #print(f"last value is {sht.Cells(bottom, 1).Value}")
38
39 for rowNumb in range(2,bottom+1):
40 fullName = sht.Cells(rowNumb,2).Value.upper()
41 fullName = fullName.split("*")[0]
42 emailAddress = sht.Cells(rowNumb,3).Value.upper()
43 if emailAddress in list(emailAddressMatrix.keys()):
44 if emailAddressMatrix[emailAddress] == fullName:
45 pass
46 else:
47 print("ERROR: Multiple unique names for the same email address!!!")
48 else:
49 emailAddressMatrix[emailAddress] = fullName
50 #print(f"{sht.Cells(rowNumb,2).Value} | {sht.Cells(rowNumb,3).Value}")
51
52 xlBook.Close()
53
54 for address in list(emailAddressMatrix.keys()):
55 outputFile.write(f"{address}|{emailAddressMatrix[address]}\n")
56
57 outputFile.close()
58
59