-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathke_lab7_draft
More file actions
71 lines (57 loc) · 1.91 KB
/
ke_lab7_draft
File metadata and controls
71 lines (57 loc) · 1.91 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 03 16:15:47 2017
@author: Kody Ellis
"""
import numpy
record_dates = []
barometric_p = []
humid = []
#file, string
def weatherStats(field, aWeatherFile = "weather_data.csv"):
""""This opens up a designated file that should be weather data.csv
The program then starts to read the file. For every line in the file, if
it starts with a '#' or a non-numerical character the program skips it.
If the file has a numerical chracter, it starts to append data to a list
using the split() function. The field parameter is for getting
certain types of data, as each increase in the field starting from 0 will
return a new field of data.
For example is field = 2 then the field will
return all data for relative humidity.
"""
file_connector = open(aWeatherFile, "r")
field_data = []
#prints baromeric pressure
for line in file_connector:
if line[0] == "#" or (not line [0].isdigit()) :
pass
else:
#only gets items from date
#if line.split()[0] == "11/1/2017":
#split(",")[2] takes relative humidity
field_data.append(float(line.split()[1].split(",")[field]))
file_connector.close()
return field_data
barometric_p = min(weatherStats(1))
humid = max(weatherStats(2))
temperature = numpy.mean(weatherStats(3))
wind_direction = numpy.median(weatherStats(4))
wind_speed = numpy.mean(weatherStats(5))
print barometric_p
print humid
print temperature
print wind_direction
print wind_speed
#
#print max(barometric_p)
#close conenction
#data = file_connector.read()
#This prints out all data becasue of the 2 in line.split()[2]
#for line in file_connector:
# if line[0] == "#" or (not line [0].isdigit()) :
# pass
# else:
# humid.append(float(line.split()[2].split(",")[2]))
#
#print humid
#