ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Redgrave/NS-CategoricalGroupedLogCreator.py
Revision: 969
Committed: Mon Feb 9 20:45:17 2026 UTC (6 weeks, 4 days ago) by nino.borges
Content type: text/x-python
File size: 2315 byte(s)
Log Message:
First version of a program that will create the grouped concatenated categorical log where there is a row only for each unique priv description.

File Contents

# User Rev Content
1 nino.borges 969 """
2    
3     NS-CategoricalGroupedLogCreator
4    
5     Created by:
6     Emanuel Borges
7     02.09.2026
8    
9     This program will create the grouped concatenated categorical log where there is a row only for each unique priv description.
10    
11     """
12    
13     from __future__ import annotations
14    
15     from dataclasses import dataclass, field
16     from datetime import date
17     from typing import Dict, Iterable, Optional, Set
18    
19     from win32com.client import Dispatch
20    
21     version = '0.1'
22    
23     @dataclass
24     class DocValues:
25     BegDate_val: Optional[date] = None
26     EndDate_val: Optional[date] = None
27     Participants_val: Set[str] = field(default_factory=set)
28     PrivilegeTypes_val: Set[str] = field(default_factory=set)
29     DocCount_val: int = 0
30    
31    
32     def update(self, doc_date: Optional[date], participants: Iterable[str], privilege_types: Iterable[str]) -> None:
33     ## Count
34     self.DocCount_val +=1
35    
36     ## Dates (if the doc_date is known)
37     if doc_date is not None:
38     if self.BegDate_val is None or doc_date < self.BegDate_val:
39     self.BegDate_val = doc_date
40     if self.EndDate_val is None or doc_date > self.EndDAte_val:
41     self.EndDate_val = doc_date
42    
43    
44     ## Participants
45     for p in participants:
46     p = p.strip()
47     if p:
48     self.Participants_val.add(p)
49    
50    
51     ## Privilege Types
52     for t in privilege_types:
53     t = t.strip()
54     if t:
55     self.PrivilegeTypes_val.add(t)
56    
57     catLogMatrix: Dict[str, DocValues] = {}
58    
59    
60    
61     class CreateGroupedCategoricalLog(object):
62     def __init__(self, pathToExcelSpreadsheet, totalNumberOfRows, privDescriptionColumnLetter, docDatesColumnLettersList, participantsColumnLettersList, privilegeTypeColumnLetter):
63     """privDescriptionColumnLetter and privilegeTypeColumnLetter should each be a single column letter value. docDatesColumnLettersList can be a list of column letter values where the
64     value will be taked from the first column in the list that contains a value. participantsColumnLettersList should be a list of all column letters that contain participants, which
65     will be added to a de-duplicated set."""
66    
67    
68    
69     if __name__ == '__main__':
70     inputSpreadsheetLog = r""
71     outputSpreadsheetLog = r""
72    
73