ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/RandomCodeRequests/HoneyWell_reqs.txt
(Generate patch)

Comparing Python/NinoCode/RandomCodeRequests/HoneyWell_reqs.txt (file contents):
Revision 565 by nino.borges, Tue Nov 25 15:54:29 2014 UTC vs.
Revision 566 by nino.borges, Wed Jan 14 17:17:49 2015 UTC

# Line 1 | Line 1
1 + === Here I was asked to group dup documents using a field where they are putting in the
2 +        dup values ===
3 + == First I made the matrix, flatening the data into “groups” ==
4 + >>> matrix = {}
5 + >>> contents = open(r"/Users/ninoborges/Dropbox/Misc/359.txt").readlines()
6 + >>> matrix2 = {}
7 + >>> count = 1
8 + >>> for line in contents:
9 +        line = line.replace("\n","")
10 +        line = line.replace("\r","")
11 +        line = line.split("|")
12 +        test = None
13 +        for docID in line:
14 +                if docID in matrix.keys():
15 +                        test = matrix[docID]
16 +        if test:
17 +                pass
18 +        else:
19 +                test = count
20 +                count = count + 1
21 +        for docID in line:
22 +                matrix[docID] = test
23 +
24 + >>> len(matrix.keys())
25 + >>> for begNo in matrix.keys():
26 +        group = matrix[begNo]
27 +        if group in matrix2.keys():
28 +                if begNo in matrix2[group]:
29 +                        pass
30 +                else:
31 +                        matrix2[group].append(begNo)
32 +        else:
33 +                matrix2[group] = [begNo,]
34 +
35 + >>> outputFile = open(r"/Users/ninoborges/Dropbox/Misc/359_export.txt",'w')
36 + >>> for i in matrix2.keys():
37 +        outputFile.write(str(matrix2[i])+"\n")
38 +
39 +        
40 + >>> outputFile.close()
41 + >>> len(matrix2.keys())
42 + == Now use a list as the prefered “original” list ==
43 + >>> contents = open(r"/Users/ninoborges/Dropbox/Misc/originals_list.dat").readlines()
44 + >>> origList = []
45 + >>> for line in contents:
46 +        line = line.replace("\n","")
47 +        origList.append(line)
48 +
49 +        
50 + >>> len(origList)
51 +
52 + == now unpack and if it’s in the orig list, use that, if not use the smaller one. ==
53 + >>> outputFile = open(r"/Users/ninoborges/Dropbox/Misc/finalReport.txt",'w')
54 + >>> for k in matrix2.keys():
55 +        group = matrix2[k]
56 +        group.sort()
57 +        parent = None
58 +        for orig in origList:
59 +                if orig in group:
60 +                        parent = orig
61 +        if parent:
62 +                outputFile.write(parent + "|")
63 +                for i in group:
64 +                        if i == parent:
65 +                                pass
66 +                        else:
67 +                                outputFile.write(i+",")
68 +        else:
69 +                outputFile.write(group[0]+"|")
70 +                for i in group[1:]:
71 +                        outputFile.write(i+",")
72 +        outputFile.write('\n')
73 +
74 +        
75 + >>> outputFile.close()
76 + ===end===
77 +
78   === Here I was asked to make a report of the relates to but using priority tags ===
79   == First I take the priority scale that they gave me into a dict ==
80   contents = open(r"C:\Users\eborges\Box Sync\Client\Honeywell\Perligo\Project_RelatesTo_Priority\Group A\GroupA_pri.txt").readlines()

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)