-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoaa-all-rows.rb
90 lines (84 loc) · 2.04 KB
/
noaa-all-rows.rb
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# What a difference a colon makes!
File.open("data/wksst8110.for") do |file|
weeks = []
until file.eof?
week = {
date: file.read(10).strip,
temps: {}
}
#these :nino things are symbol keys made on the fly.
[:nino12, :nino3, :nino34, :nino4].each do |region|
week[:temps][region] = {
temp: file.read(9).to_f,
change: file.read(4).to_f
}
end
file.read(1)
weeks << week
end
weeks
end
# [
# [ 0] {
# :date => "03JAN1990",
# :temps => {
# :nino12 => {
# :temp => 23.4,
# :change => -0.4
# },
# :nino3 => {
# :temp => 25.1,
# :change => -0.3
# },
# :nino34 => {
# :temp => 26.6,
# :change => 0.0
# },
# :nino4 => {
# :temp => 28.6,
# :change => 0.3
# }
# }
# },
# [ 1] {
# :date => "10JAN1990",
# :temps => {
# :nino12 => {
# :temp => 23.4,
# :change => -0.8
# },
# :nino3 => {
# :temp => 25.2,
# :change => -0.3
# },
# :nino34 => {
# :temp => 26.6,
# :change => 0.1
# },
# :nino4 => {
# :temp => 28.6,
# :change => 0.3
# }
# }
# },
# [ 2] {
# :date => "17JAN1990",
# :temps => {
# :nino12 => {
# :temp => 24.2,
# :change => -0.3
# },
# :nino3 => {
# :temp => 25.3,
# :change => -0.3
# },
# :nino34 => {
# :temp => 26.5,
# :change => -0.1
# },
# :nino4 => {
# :temp => 28.6,
# :change => 0.3
# }
# }
# },