ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Redgrave/ATT-RelativitySearchReport.py
Revision: 883
Committed: Thu May 22 19:55:29 2025 UTC (10 months ago) by nino.borges
Content type: text/x-python
File size: 3448 byte(s)
Log Message:
Added ability for it to create the formatted spreadsheet.

File Contents

# Content
1 """
2
3 ATT-RelativitySearchReport
4
5 Created by:
6 Emanuel Borges
7 05.6.2025
8
9 This very simple program will take a Relativity saved search information export and convert it to a more useful report that can be shared with others and contains
10 detail contained in the notes section of the search. This assumes the best practice of notating what the search does in the Notes field.
11
12 """
13
14
15 import os, csv, pathlib
16 from win32com.client import Dispatch
17
18 version = "0.03"
19
20
21 if __name__ == '__main__':
22 rawReportFile = r"C:\Test_Dir\ATT\export_20250522_174604.csv"
23 outputFilename = r"C:\Test_Dir\ATT\export_20250522_174604_OUT.XLSX"
24 headerRow = ["Artifact ID", "Search Name", "Notes"]
25
26 ## For Lighthouse
27 relativityInstancePath = 'https://relativity4.lighthouseglobal.com/Relativity/'
28
29 ## For shiny
30 #workspaceArtifactID = '1267840'
31 ## For Vermont
32 workspaceArtifactID = '1530226'
33
34
35 reportMatrix = {}
36
37 with open(rawReportFile,encoding='UTF-8') as csvFile:
38 csvReader = csv.DictReader(csvFile,delimiter=',',quotechar='"')
39 for row in csvReader:
40
41 pathParts = pathlib.Path(row['Path'].replace(row['Name'],''))
42 rowFolderName = "\\".join(pathParts.parts[1:-1])
43
44 if rowFolderName in list(reportMatrix.keys()):
45 reportMatrix[rowFolderName].append((row['Name'],row['Notes'],f"{relativityInstancePath}go?id={workspaceArtifactID}-{row['Artifact ID']}", row['Artifact ID']))
46 else:
47 reportMatrix[rowFolderName] = [(row['Name'],row['Notes'],f"{relativityInstancePath}go?id={workspaceArtifactID}-{row['Artifact ID']}", row['Artifact ID']),]
48 #print(f"{row['Artifact ID']} | {rowFolderName} | {row['Name']} | {row['Notes']} | {relativityInstancePath}go?id={workspaceArtifactID}-{row['Artifact ID']}" )
49
50 folderGroupList = list(reportMatrix.keys())
51 folderGroupList.sort()
52
53
54 xlApp = Dispatch('Excel.Application')
55 xlBook = xlApp.Workbooks.Add()
56 sht = xlBook.Worksheets(1)
57 colNumb = 1
58 for fName in headerRow:
59 sht.Cells(1,colNumb).Value = fName
60 colNumb +=1
61
62 rowNumb = 2
63
64 for folderName in folderGroupList:
65 colNumb = 2
66 print(folderName)
67 sht.Cells(rowNumb,colNumb).Value = folderName
68 sht.Cells(rowNumb,colNumb).Interior.Color = 12632256
69 sht.Cells(rowNumb,colNumb+1).Interior.Color = 12632256
70 folderSearches = reportMatrix[folderName]
71 folderSearches.sort()
72 rowNumb +=1
73 for srch in folderSearches:
74 colNumb = 1
75 print(f"\t{srch}")
76 ## Write the artifact ID
77 sht.Cells(rowNumb,colNumb).Value = srch[-1]
78 colNumb +=1
79 ## Write the search name
80 sht.Cells(rowNumb,colNumb).Value = srch[0]
81 ## Make it a real hyperlink
82 sht.Hyperlinks.Add(sht.Range(f"B{rowNumb}"), Address = srch[2])
83 colNumb +=1
84 ## Write the Notes
85 sht.Cells(rowNumb,colNumb).Value = srch[1]
86 colNumb +=1
87
88 #for value in srch:
89 # sht.Cells(rowNumb,colNumb).Value = value
90 # colNumb +=1
91 rowNumb +=1
92 sht.Columns("A:A").Hidden = True
93 #sht.Hyperlinks.Add(sht.Range("D6"), Address = "https://www.foo.com")
94 xlBook.SaveAs(outputFilename)
95 xlApp.Quit()