Created
June 20, 2014 07:31
-
-
Save unRob/3c822a5c3efc4644c6d2 to your computer and use it in GitHub Desktop.
Promedios mensuales de IMECA por mes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'csv' | |
meses = 1..12 | |
valores = [0]*12 | |
data = Hash[meses.zip valores] | |
dpm = Hash[meses.zip valores] | |
cols = [6,11,16,21,26] | |
# Este archivo sale de alguno de los años de http://www.calidadaire.df.gob.mx/calidadaire/index.php?opcion=2&opcioninfoproductos=22 | |
CSV.foreach("./imeca.csv") do |row| | |
f = row[0].split('/')[0].to_i rescue next | |
d = [] | |
cols.each do |c| | |
d.push row[c].to_i | |
end | |
data[f] += d.inject(:+)/d.count | |
dpm[f] += 1 | |
end | |
data.each do |k, v| | |
puts v.to_f/dpm[k].to_f | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment