| 1 |
nino.borges |
934 |
"""
|
| 2 |
|
|
|
| 3 |
|
|
EmptyFieldReport
|
| 4 |
|
|
|
| 5 |
|
|
Created by:
|
| 6 |
|
|
Emanuel Borges
|
| 7 |
|
|
03.13.2025
|
| 8 |
|
|
|
| 9 |
|
|
This program will analyze a cleaned dat file and tell you which fields have data in them and which fields are empty. This expects a pipe delimited dat file that has been cleaned
|
| 10 |
|
|
and that the first line is the headder row.
|
| 11 |
|
|
|
| 12 |
|
|
"""
|
| 13 |
|
|
|
| 14 |
|
|
|
| 15 |
|
|
|
| 16 |
|
|
|
| 17 |
|
|
|
| 18 |
|
|
|
| 19 |
|
|
|
| 20 |
|
|
if __name__ == '__main__':
|
| 21 |
|
|
#inputDatFile = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\AT&T\Cybersecurity FCA Case\PrivFieldAnalysis\Vermont\Vermont-AllDocs-AllPrivFields_Converted.txt"
|
| 22 |
|
|
inputDatFile = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\AT&T\Cybersecurity FCA Case\PrivFieldAnalysis\Shiny\Shiny-AllDocs-AllPrivFields_Converted.txt"
|
| 23 |
|
|
|
| 24 |
|
|
|
| 25 |
|
|
contents = open(inputDatFile,encoding='UTF-8').readlines()
|
| 26 |
|
|
headder = contents[0]
|
| 27 |
|
|
contents = contents[1:]
|
| 28 |
|
|
print(f"There are {len(contents)} rows of data in this file.\n\n")
|
| 29 |
|
|
|
| 30 |
|
|
|
| 31 |
|
|
headder = headder.replace("\n","")
|
| 32 |
|
|
headder = headder.split("|")
|
| 33 |
|
|
print(f"There are {len(headder)} fields in this file.\n\n")
|
| 34 |
|
|
|
| 35 |
|
|
|
| 36 |
|
|
hasData = []
|
| 37 |
|
|
noData = []
|
| 38 |
|
|
headderMatrix = {}
|
| 39 |
|
|
for i in headder:
|
| 40 |
|
|
headderMatrix[headder.index(i)] = i
|
| 41 |
|
|
noData = headder.copy()
|
| 42 |
|
|
|
| 43 |
|
|
|
| 44 |
|
|
for line in contents:
|
| 45 |
|
|
line = line.replace("\n","")
|
| 46 |
|
|
line = line.split("|")
|
| 47 |
|
|
for idVal, val in enumerate(line):
|
| 48 |
|
|
if val:
|
| 49 |
|
|
if headderMatrix[idVal] in noData:
|
| 50 |
|
|
noData.remove(headderMatrix[idVal])
|
| 51 |
|
|
hasData.append(headderMatrix[idVal])
|
| 52 |
|
|
|
| 53 |
|
|
|
| 54 |
|
|
print(f"There are {len(hasData)} fields that contain data and {len(noData)} field that are totally empty.\n\n")
|
| 55 |
|
|
|
| 56 |
|
|
|
| 57 |
|
|
noData.sort()
|
| 58 |
|
|
hasData.sort()
|
| 59 |
|
|
|
| 60 |
|
|
print("Here is the list of fields with NO data:")
|
| 61 |
|
|
for x in noData:
|
| 62 |
|
|
print(x)
|
| 63 |
|
|
|
| 64 |
|
|
|
| 65 |
|
|
print("\n\nHere is the list of fields that do contain data:")
|
| 66 |
|
|
for x in hasData:
|
| 67 |
|
|
print(x) |