ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Relativity/HPPR_ReportParser.py
Revision: 564
Committed: Tue Nov 25 20:46:59 2014 UTC (11 years, 4 months ago) by nino.borges
Content type: text/x-python
File size: 4449 byte(s)
Log Message:
added the init to the folder to make it callable. Finished the db clases. Started the reporting class.

File Contents

# User Rev Content
1 nino.borges 561 """
2    
3     HPPR_ReportParser.py
4    
5     This program will take a history export from the HPPR and parse and hten make a spreadsheet
6     with the results.
7     """
8    
9    
10     class DB_View:
11 nino.borges 564 def __init__(self,begno,viewDate):
12     self.begNo = begno
13     self.viewCount = 1
14     self.viewDateList = [viewDate,]
15     def AddToViewDateList(self,date):
16     """Adds value to view date list"""
17     self.viewDateList.append(date)
18     def IncrementViewCount (self,n=1):
19     """Increments the viewcount. default if to increment by 1"""
20     self.viewCount += n
21 nino.borges 561 def ReturnInformation(self,info):
22     data = getattr(self,info)
23     return data
24     def SaveInformation(self,field,info):
25     data = setattr(self,field,info)
26    
27     class DB_Print:
28 nino.borges 564 def __init__(self,begno,printDate):
29     self.begNo = begno
30     self.printCount = 1
31     self.printDateList = [printDate,]
32     def AddToPrintDateList(self,date):
33     """Adds value to print date list"""
34     self.printDateList.append(date)
35     def IncrementPrintCount (self,n=1):
36     """Increments the viewcount. default if to increment by 1"""
37     self.printCount += n
38 nino.borges 561 def ReturnInformation(self,info):
39     data = getattr(self,info)
40     return data
41     def SaveInformation(self,field,info):
42     data = setattr(self,field,info)
43    
44     class DB_Query:
45     def __init__(self,begno):
46     self.BegNo = begno
47     def ReturnInformation(self,info):
48     data = getattr(self,info)
49     return data
50     def SaveInformation(self,field,info):
51     data = setattr(self,field,info)
52    
53 nino.borges 564 class Reporting:
54     def __init__(self):
55     self.activityByDocFile = r"C:\McDermott-Discovery\Client\activityByDocument.txt"
56     def CreateActivityByDocReport(viewedMatrix,printedMatrix):
57     """ Creates the activity by document report"""
58     outputFile = open(self.activityByDocFile,'w')
59     viewedList = viewedMatrix.keys()
60     printedList = printedMatrix.keys()
61     combinedList = viewedList + list(set(printedList) - set(viewedList))
62    
63    
64 nino.borges 561 if __name__ == '__main__':
65 nino.borges 564 documentsQueried = []
66     documentsPrintedMatrix = {}
67     documentPrinted = []
68     documentsViewedMatrix = {}
69     documentsViewed = []
70     reportFile = r"\\BSTDD967DTW1\Users\eborges\Box Sync\Client\Honeywell\HPPR\Reporting\Don_report.dat"
71    
72 nino.borges 561 contents = open(reportFile).readlines()
73 nino.borges 564 contents = contents[1:]
74    
75     ## First we pack the objs into the lists.
76    
77 nino.borges 561 for line in contents:
78 nino.borges 564 line = line.replace("\n","")
79 nino.borges 561 line = line.split("|")
80 nino.borges 564 actionType = line[1]
81     if actionType == "View":
82     docID = line[0]
83     date = line[4]
84     if docID in documentsViewedMatrix.keys():
85     documentsViewedMatrix[docID].IncrementViewCount()
86     documentsViewedMatrix[docID].AddToViewDateList(date)
87     else:
88     docObj = DB_View(docID,date)
89     documentsViewedMatrix[docID] = docObj
90     elif actionType == "Document Query":
91     pass
92     elif actionType == "Print":
93     docID = line[0]
94     date = line[4]
95     if docID in documentsPrintedMatrix.keys():
96     documentsPrintedMatrix[docID].IncrementPrintCount()
97     documentsPrintedMatrix[docID].AddToPrintDateList(date)
98     else:
99     docObj = DB_Print(docID,date)
100     documentsPrintedMatrix[docID] = docObj
101     else:
102     print "ERROR: Unsupported action type - %s"% actionType
103    
104     ## Then we unpack into the report.
105     printReport = open(r"C:\McDermott-Discovery\Client\printReport.txt",'w')
106     viewReport = open(r"C:\McDermott-Discovery\Client\viewReport.txt","w")
107     for i in documentsPrintedMatrix.keys():
108     printReport.write("%s was printed %s times on the following dates:"% (i,documentsPrintedMatrix[i].printCount))
109     for x in documentsPrintedMatrix[i].printDateList:
110     printReport.write("%s,"%x)
111     printReport.write("\n")
112     for i in documentsViewedMatrix.keys():
113     viewReport.write("%s was Viewed %s times on the following dates:"% (i,documentsViewedMatrix[i].viewCount))
114     for x in documentsViewedMatrix[i].viewDateList:
115     viewReport.write("%s,"%x)
116     viewReport.write("\n")
117     printReport.close()
118     viewReport.close()
119    
120