-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph_average_temp.py
30 lines (28 loc) · 1.08 KB
/
graph_average_temp.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
#!/usr/bin/python
import os, csv, statistics
maxdict = {}
mindict = {}
for directory, folders, files in os.walk(r'C:\Users\ivazirabad\AdvancedDataScience\YearlyClimate\curated'):
for f in files:
filename = os.path.splitext(f)[0]
print(filename)
with open(os.path.join(directory, f)) as infile:
infile.readline()
climatereader = csv.reader(infile, delimiter=',', quotechar='"')
for row in climatereader:
if filename not in maxdict:
maxdict[filename] = [float(row[-3])]
else:
maxdict[filename].append(float(row[-3]))
if filename not in mindict:
mindict[filename] = [float(row[-2])]
else:
mindict[filename].append(float(row[-2]))
maxdict[filename] = statistics.mean(maxdict[filename])
mindict[filename] = statistics.mean(mindict[filename])
print('\nMAX')
for k, v in maxdict.items():
print(k, v, sep='\t')
print('\nMIN')
for k, v in mindict.items():
print(k, v, sep='\t')