Sha256: 3f4b0f8c3b4b149252e26efcd4dcfd8aceb7d7ea45e1d5bb91e603884081cf91

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

require 'earth/eia'
require 'earth/locality/data_miner'

MecsRatio.class_eval do
  const_set(:CENSUS_REGIONS, {
    'Total US' =>  {
      :crop => (16..95),
      :code => nil
    },
    'Northeast' => {
      :crop => (100..179),
      :code => 1
    },
    'Midwest' => {
      :crop => (184..263),
      :code => 2
    },
    'South' =>  {
      :crop => (268..347),
      :code => 3
    },
    'West' => {
      :crop => (352..431),
      :code => 4
    }
  })
  
  data_miner do
    MecsRatio::CENSUS_REGIONS.each do |region, data|
      import( "MECS table 6.1 #{region}",
        :url => "http://205.254.135.24/emeu/mecs/mecs2006/excel/Table6_1.xls",
        :crop => data[:crop],
        :headers => ["NAICS Code", "Subsector and Industry", "Consumption per Employee", "Consumption per Dollar of Value Added", "Consumption per Dollar of Value of Shipments"]) do
        key :name, :synthesize => Proc.new { |row| "#{Industry.format_naics_code(row["NAICS Code"])}-#{data[:code]}" }
        store :census_region_number, :static => data[:code]
        store :naics_code, :synthesize => Proc.new { |row| Industry.format_naics_code row["NAICS Code"] }
        store :energy_per_dollar_of_shipments, :units => :megajoules, :synthesize => Proc.new { |row|
          Earth::EIA.convert_value(row['Consumption per Dollar of Value of Shipments'], :from => :kbtus, :to => :megajoules)
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
earth-0.11.17 lib/earth/industry/mecs_ratio/data_miner.rb
earth-0.11.16 lib/earth/industry/mecs_ratio/data_miner.rb
earth-0.11.15 lib/earth/industry/mecs_ratio/data_miner.rb
earth-0.11.14 lib/earth/industry/mecs_ratio/data_miner.rb
earth-0.11.13 lib/earth/industry/mecs_ratio/data_miner.rb
earth-0.11.12 lib/earth/industry/mecs_ratio/data_miner.rb
earth-0.11.11 lib/earth/industry/mecs_ratio/data_miner.rb