ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Redgrave/PrivilegeLogFieldCompare.py
Revision: 914
Committed: Fri Aug 1 21:28:18 2025 UTC (7 months, 3 weeks ago) by nino.borges
Content type: text/x-python
File size: 3104 byte(s)
Log Message:
This program will take a DAT export from Relativity and will compare the values in the fields.

File Contents

# User Rev Content
1 nino.borges 914 """
2    
3     PrivilegeLogFieldCompare
4    
5     Created by:
6     Emanuel Borges
7     07.23.2025
8    
9     This program will take a DAT export from Relativity and will compare the values in the fields.
10    
11     """
12    
13    
14     import csv
15    
16    
17     class ConcordanceLoader:
18     def __init__(self, filePath):
19     self.filePath = filePath
20     self.delimiter = '\x14' # ASCII 20
21     self.quotechar = '\xfe' # ASCII 254
22     self.records = []
23    
24    
25     def load(self):
26     with open(self.filePath, 'r', encoding='utf-8', newline='') as file:
27     reader = csv.reader(file, delimiter = self.delimiter, quotechar = self.quotechar)
28     self.records = [row for row in reader]
29    
30    
31     def get_headers(self):
32     return self.records[0] if self.records else []
33    
34     def get_data(self):
35     return self.records[1:] if len(self.records) >1 else []
36    
37     def get_all(self):
38     return self.records
39    
40    
41     def compare_fields(self, report_on_field: str, field_name_a: str, field_name_b: str):
42     """Will compare the values in two different fields. report on should be the REVIEWID field"""
43     if not self.records:
44     raise ValueError("No data loaded. Run .load() first.")
45    
46     headers = self.get_headers()
47     try:
48     report_idx = headers.index(report_on_field)
49     first_field_idx = headers.index(field_name_a)
50     second_field_idx = headers.index(field_name_b)
51     except ValueError as e:
52     raise ValueError(f"Column not found: {e}")
53    
54     for row_num, row in enumerate(self.get_data(), start=2): # Use Excel-style row numbers
55     report_val = row[report_idx] if report_idx < len(row) else ''
56     first_field_val = row[first_field_idx] if first_field_idx < len(row) else ''
57     second_field_val = row[second_field_idx] if second_field_idx < len(row) else ''
58     ## For now I only care if the PLOG field has data.
59     if second_field_val:
60     sVals = second_field_val.split(";")
61     sVals.sort()
62     if first_field_val:
63     fVals = first_field_val.split(";")
64     fVals.sort()
65     sTest = [s.upper().strip() for s in sVals]
66     fTest = [f.upper().strip() for f in fVals]
67     if sTest != fTest:
68     print(f"{report_val}: Values in {field_name_b} are different from those in {field_name_a}.")
69     else:
70     print(f"{report_val}: Value in {field_name_b} but {field_name_a} is empty.")
71    
72     if __name__ == '__main__':
73     ## Full path to the DAT input file
74     inputFilePath = r"C:\Test_Dir\ATT\20250723_PLOG_FieldCompare\20250723 - PrivLog001_fieldAnalysis(w_PLOG).dat"
75    
76     loader = ConcordanceLoader(inputFilePath)
77     loader.load()
78    
79     #loader.compare_fields("REVIEWID", "MA Normalized To::Full Name", "PLOG Recipients")
80     #loader.compare_fields("REVIEWID", "MA Normalized Cc::Full Name", "PLOG CC")
81     loader.compare_fields("REVIEWID", "MA Normalized To::Full Name", "To")
82    
83