ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/IncomingProdAnalyzer.py
Revision: 677
Committed: Fri May 1 14:48:48 2020 UTC (5 years, 10 months ago) by nino.borges
Content type: text/x-python
File size: 1958 byte(s)
Log Message:
No real changes.

File Contents

# User Rev Content
1 nino.borges 672 """
2    
3     IncomingProdAnalyzer
4    
5     Created by
6     Emanuel Borges
7     2020.02.07
8    
9     A simple program that I can point to a DAT and it will analyze it for issues like columns not lining up,
10     what fields they gave in the headder and which ones have stuff and which are totally empty, etc.
11    
12     """
13    
14     if __name__ == '__main__':
15     matrix = {}
16     headderMatrix = {}
17 nino.borges 677 datFilePath = r"\\sas44\sas44\34275\Inbound\10\98538\HRLP006\DATA\HRLP006.DAT"
18 nino.borges 672 quoteChar = "\xfe"
19     delim = "\x14"
20    
21     contents = open(datFilePath).readlines()
22    
23     headder = contents[0]
24     headder = headder.replace(quoteChar,"")
25     headder = headder.split(delim)
26     ## This headder Matrix is really to look up at the end. I dont use it for the main matrix below.
27     for hSpot, hFieldName in enumerate(headder):
28     headderMatrix[hSpot] = hFieldName
29     numberOfFields = len(headder)
30     contents = contents[1:]
31    
32    
33     print "Analyzing file..."
34     print "There are %s records in this load."%len(contents)
35     for line in contents:
36     line = line.replace("\n","")
37     line = line.replace(quoteChar,"")
38     line = line.split(delim)
39     if len(line) == numberOfFields:
40     pass
41     else:
42     print "Warning: number of fields for this line doenst match."
43     for itemSpot, value in enumerate(line):
44     if value:
45     matrix[itemSpot] = 1
46    
47     print "Analysis completed."
48     print ""
49     print "-"*10
50     print "The following fields exist in this DAT:"
51     for i in headder:
52     print i
53     print "-"*10
54     print ""
55     print "The following fields actually contains *some* data:"
56     for spot in matrix.keys():
57     print headder[spot]
58    
59     print "-"*10
60     print ""
61     print "The following fields are totally empty:"
62     for hSpot in headderMatrix.keys():
63     if hSpot in matrix.keys():
64     pass
65     else:
66     print headderMatrix[hSpot]
67