| 1 |
nino.borges |
882 |
"""
|
| 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 |
nino.borges |
883 |
from win32com.client import Dispatch
|
| 17 |
nino.borges |
882 |
|
| 18 |
nino.borges |
892 |
version = "0.04"
|
| 19 |
nino.borges |
882 |
|
| 20 |
|
|
|
| 21 |
nino.borges |
892 |
def GenerateSearchReport(rawReportFile, outputFilename, relativityInstancePath, workspaceArtifactID):
|
| 22 |
|
|
"""test"""
|
| 23 |
nino.borges |
883 |
headerRow = ["Artifact ID", "Search Name", "Notes"]
|
| 24 |
nino.borges |
892 |
|
| 25 |
nino.borges |
883 |
reportMatrix = {}
|
| 26 |
|
|
|
| 27 |
|
|
with open(rawReportFile,encoding='UTF-8') as csvFile:
|
| 28 |
nino.borges |
882 |
csvReader = csv.DictReader(csvFile,delimiter=',',quotechar='"')
|
| 29 |
|
|
for row in csvReader:
|
| 30 |
nino.borges |
883 |
|
| 31 |
|
|
pathParts = pathlib.Path(row['Path'].replace(row['Name'],''))
|
| 32 |
|
|
rowFolderName = "\\".join(pathParts.parts[1:-1])
|
| 33 |
|
|
|
| 34 |
|
|
if rowFolderName in list(reportMatrix.keys()):
|
| 35 |
|
|
reportMatrix[rowFolderName].append((row['Name'],row['Notes'],f"{relativityInstancePath}go?id={workspaceArtifactID}-{row['Artifact ID']}", row['Artifact ID']))
|
| 36 |
|
|
else:
|
| 37 |
|
|
reportMatrix[rowFolderName] = [(row['Name'],row['Notes'],f"{relativityInstancePath}go?id={workspaceArtifactID}-{row['Artifact ID']}", row['Artifact ID']),]
|
| 38 |
|
|
#print(f"{row['Artifact ID']} | {rowFolderName} | {row['Name']} | {row['Notes']} | {relativityInstancePath}go?id={workspaceArtifactID}-{row['Artifact ID']}" )
|
| 39 |
|
|
|
| 40 |
|
|
folderGroupList = list(reportMatrix.keys())
|
| 41 |
|
|
folderGroupList.sort()
|
| 42 |
|
|
|
| 43 |
|
|
|
| 44 |
|
|
xlApp = Dispatch('Excel.Application')
|
| 45 |
|
|
xlBook = xlApp.Workbooks.Add()
|
| 46 |
|
|
sht = xlBook.Worksheets(1)
|
| 47 |
|
|
colNumb = 1
|
| 48 |
|
|
for fName in headerRow:
|
| 49 |
|
|
sht.Cells(1,colNumb).Value = fName
|
| 50 |
|
|
colNumb +=1
|
| 51 |
|
|
|
| 52 |
|
|
rowNumb = 2
|
| 53 |
|
|
|
| 54 |
|
|
for folderName in folderGroupList:
|
| 55 |
|
|
colNumb = 2
|
| 56 |
|
|
print(folderName)
|
| 57 |
|
|
sht.Cells(rowNumb,colNumb).Value = folderName
|
| 58 |
|
|
sht.Cells(rowNumb,colNumb).Interior.Color = 12632256
|
| 59 |
|
|
sht.Cells(rowNumb,colNumb+1).Interior.Color = 12632256
|
| 60 |
|
|
folderSearches = reportMatrix[folderName]
|
| 61 |
|
|
folderSearches.sort()
|
| 62 |
|
|
rowNumb +=1
|
| 63 |
|
|
for srch in folderSearches:
|
| 64 |
|
|
colNumb = 1
|
| 65 |
|
|
print(f"\t{srch}")
|
| 66 |
|
|
## Write the artifact ID
|
| 67 |
|
|
sht.Cells(rowNumb,colNumb).Value = srch[-1]
|
| 68 |
|
|
colNumb +=1
|
| 69 |
|
|
## Write the search name
|
| 70 |
|
|
sht.Cells(rowNumb,colNumb).Value = srch[0]
|
| 71 |
|
|
## Make it a real hyperlink
|
| 72 |
|
|
sht.Hyperlinks.Add(sht.Range(f"B{rowNumb}"), Address = srch[2])
|
| 73 |
|
|
colNumb +=1
|
| 74 |
|
|
## Write the Notes
|
| 75 |
|
|
sht.Cells(rowNumb,colNumb).Value = srch[1]
|
| 76 |
|
|
colNumb +=1
|
| 77 |
|
|
|
| 78 |
|
|
#for value in srch:
|
| 79 |
|
|
# sht.Cells(rowNumb,colNumb).Value = value
|
| 80 |
|
|
# colNumb +=1
|
| 81 |
|
|
rowNumb +=1
|
| 82 |
|
|
sht.Columns("A:A").Hidden = True
|
| 83 |
|
|
#sht.Hyperlinks.Add(sht.Range("D6"), Address = "https://www.foo.com")
|
| 84 |
|
|
xlBook.SaveAs(outputFilename)
|
| 85 |
nino.borges |
892 |
xlApp.Quit()
|
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
if __name__ == '__main__':
|
| 89 |
|
|
rawReportFile = r"C:\Test_Dir\ATT\export_20250522_174604.csv"
|
| 90 |
|
|
outputFilename = r"C:\Test_Dir\ATT\export_20250522_174604_OUT2.XLSX"
|
| 91 |
|
|
|
| 92 |
|
|
|
| 93 |
|
|
## For Lighthouse
|
| 94 |
|
|
relativityInstancePath = 'https://relativity4.lighthouseglobal.com/Relativity/'
|
| 95 |
|
|
|
| 96 |
|
|
## For shiny
|
| 97 |
|
|
#workspaceArtifactID = '1267840'
|
| 98 |
|
|
## For Vermont
|
| 99 |
|
|
workspaceArtifactID = '1530226'
|
| 100 |
|
|
|
| 101 |
|
|
|
| 102 |
|
|
GenerateSearchReport(rawReportFile, outputFilename, relativityInstancePath, workspaceArtifactID) |