-
Notifications
You must be signed in to change notification settings - Fork 0
/
count_missing.py
40 lines (30 loc) · 980 Bytes
/
count_missing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import argparse
import csv
def count_missing_row(filename):
"""
Function to count lines is missing data
"""
res = 0
listRow = []
with open(filename) as csvfile:
reader = csv.DictReader(csvfile)
listRow = [row for row in reader]
rowCount = len(listRow)
if (rowCount == 0):
return res
#Check missing value in dataset
for row in listRow:
if "" in row.values():
res += 1
return res
if (__name__ == '__main__'):
parser = argparse.ArgumentParser(description='Count rows that missing values')
parser.add_argument('files_in', metavar='file', type=str, nargs='+',
help='paths to csv file')
args = parser.parse_args()
#print(args)
for f in args.files_in:
if (len(args.files_in) > 1):
print("In file %s: " % f)
print(count_missing_row(f))