-
Notifications
You must be signed in to change notification settings - Fork 0
/
format.py
36 lines (29 loc) · 1.04 KB
/
format.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
import csv
import os
# Variable for controlling the analysis
# data:column refers to the column input data file
data_column = 5
directory = "./data"
with open("output", 'w') as output_file:
removed_count = 0
total_count = 0
output_writer = csv.writer(output_file)
for filename in os.listdir(directory):
if not filename.endswith(".csv"):
continue
with open("./data/" + filename) as data_file:
reader = csv.reader(data_file)
for row in reader:
if row and row[0] == 'Date/Time':
break
for row in reader:
data = [row[i] for i in [1,2,3,data_column]]
if data[0] == 'Year':
print(row)
print(filename)
if data.count('') == 0:
output_writer.writerow(data)
else:
removed_count += 1
total_count += 1
print("removed {}/{} entries because of missing data".format(removed_count, total_count))