ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/EvidoxFileNameCompareAndLocator.py
Revision: 746
Committed: Thu Apr 15 20:11:16 2021 UTC (4 years, 11 months ago) by nino.borges
Content type: text/x-python
File size: 2163 byte(s)
Log Message:
Updated to be compatible with python3, which made the bak files.

File Contents

# Content
1 """
2
3 EvidoxFileNameCompareAndLocator
4
5 Created by:
6 Emanuel Borges
7 08.02.2018
8
9 This program was created for Peter so that he can take two file name and file path lists, pipe delimited for now, and compare to see
10 if a filename in list A is in the full path field of list B.
11
12 Mostly for instruction for now but will eventually be built to also read XLS directly and probably have a GUI
13
14
15
16 """
17
18 import os
19
20 if __name__ == '__main__':
21 print("Analyzing Source file...")
22 ## The file with values that will be used to find in the other file
23 fileSourceContents = open(r"T:\Conn Kavanaugh\Governo-CMBG3\3187989\Search Terms Document List and File Paths (2018.07.31).csv").readlines()
24
25 print("Analyzing target file...")
26 ## The file with the target that will be searched for the values in file above.
27 fileTargetContents = open(r"T:\Conn Kavanaugh\Governo-CMBG3\3187989\Governo-CMBG3 171,403 to be searched.csv").readlines()
28
29 outputFile = open(r"C:\Test-PY\PAK\GonvernoResults.csv",'w')
30
31
32 matrix = {}
33
34 print("Creating matrix from targetFile...")
35
36 for line in fileTargetContents:
37 line = line.replace("\n","")
38 searchPath = line.split("|")[1]
39 searchTerm = os.path.split(searchPath)[1]
40 if os.path.splitext(searchTerm)[1]:
41 matrix[searchTerm.upper()] = line
42 else:
43 pass
44
45 targetSearchList = list(matrix.keys())
46
47 print("Target file matrix created.")
48
49 print("Now creating the source list...")
50 sourceSearchList = []
51
52 for line in fileSourceContents:
53 searchTerm = line.split("|")[0]
54 sourceSearchList.append(searchTerm.upper())
55
56 print("Source List created.")
57
58 print("Comparing values and writing to file...")
59 ## for term in sourceSearchList:
60 ## if term in targetSearchList:
61 ## outputFile.write(matrix[term] + "|FOUND\n")
62
63 for term in targetSearchList:
64 if term in sourceSearchList:
65 outputFile.write(matrix[term] + "|FOUND\n")
66 else:
67 outputFile.write(matrix[term] + "|NOT FOUND\n")
68
69 outputFile.close()