Created
October 23, 2011 07:25
-
-
Save lguardiola/1306991 to your computer and use it in GitHub Desktop.
Vivienda Agua Corriente
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
# encoding: utf-8 | |
Encoding.default_internal = "UTF-8" | |
Encoding.default_external = "UTF-8" | |
=begin | |
REFERENCES | |
ticket: https://www.pivotaltracker.com/story/show/20034615 | |
code: https://gist.github.com/1306991 | |
=end | |
require 'rubygems' | |
require 'roo' | |
if ARGV.size.zero? | |
$stdout.puts <<-EOF | |
USAGE: ruby #{$0} docs/maximo_nivel_de_instruccion_alcanzado_01.xls | |
EOF | |
exit 0 | |
end | |
oo = Excel.new(ARGV.first) | |
oo.default_sheet = oo.sheets.first | |
main_column = 'A' | |
data_column = 'C' | |
max_rown_main_colum = oo.column(main_column).size | |
$stdout.puts "AREA; Primario Completo; Secundario Completo; Terciario Completo; Universitario Completo" | |
1.upto(max_rown_main_colum-1) do |row_number| | |
content = oo.cell(row_number, main_column) | |
next if content.nil? | |
if content.include?('AREA #') | |
i = 0 | |
data = { | |
:area => content.split('#').last.strip, | |
:primario => 0.0, | |
:secundario => 0.0, | |
:terciario => 0.0, | |
:universitario => 0.0 | |
} | |
until (max_rown_main_colum == row_number + i) || (!content.nil? && content.include?('Total')) | |
i = i + 1 | |
content = oo.cell(row_number + i, main_column) | |
next if content.nil? | |
data.update(:primario => oo.cell(row_number + i, data_column)) if content.include?('Primario Completo') | |
data.update(:secundario => oo.cell(row_number + i, data_column)) if content.include?('Secundario Completo') | |
data.update(:terciario => oo.cell(row_number + i, data_column)) if content.include?('Terciario Completo') | |
data.update(:universitario => oo.cell(row_number + i, data_column)) if content.include?('Universitario Completo') | |
end | |
$stdout.puts data.values.join(';') | |
$stdout.flush | |
end | |
end |
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
# encoding: utf-8 | |
Encoding.default_internal = "UTF-8" | |
Encoding.default_external = "UTF-8" | |
=begin | |
REFERENCES | |
ticket: https://www.pivotaltracker.com/story/show/20034201 | |
code: https://gist.github.com/1306991 | |
=end | |
require 'rubygems' | |
require 'roo' | |
if ARGV.size.zero? | |
$stdout.puts <<-EOF | |
USAGE: ruby #{$0} docs/Rural_-_Urbano.xls | |
EOF | |
exit 0 | |
end | |
oo = Excel.new(ARGV.first) | |
oo.default_sheet = oo.sheets.first | |
main_column = 'A' | |
data_column = 'C' | |
max_rown_main_colum = oo.column(main_column).size | |
$stdout.puts "AREA;Urbana;Rural" | |
1.upto(max_rown_main_colum-1) do |row_number| | |
content = oo.cell(row_number, main_column) | |
next if content.nil? | |
if content.include?('AREA #') | |
i = 0 | |
data = { | |
:area => content.split('#').last.strip, | |
:urbana => 0.0, | |
:rural => 0.0, | |
:rural_dispersa => 0.0 | |
} | |
until (max_rown_main_colum == row_number + i) || (!content.nil? && content.include?('Total')) | |
i = i + 1 | |
content = oo.cell(row_number + i, main_column) | |
next if content.nil? | |
data.update(:urbana => oo.cell(row_number + i, data_column)) if content.include?('Urbana de 2000 personas y más') | |
data.update(:rural => oo.cell(row_number + i, data_column)) if content.include?('Rural agrupada menos de 2000 personas') | |
data.update(:rural_dispersa => oo.cell(row_number + i, data_column)) if content.include?('Rural dispersa') | |
end | |
final_data = [data.values[0], data.values[1], data.values[2,3].sum.round(2)] | |
$stdout.puts final_data.join(';') | |
$stdout.flush | |
end | |
end |
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
# encoding: utf-8 | |
Encoding.default_internal = "UTF-8" | |
Encoding.default_external = "UTF-8" | |
=begin | |
REFERENCES | |
ticket: https://www.pivotaltracker.com/story/show/20034201 | |
code: https://gist.github.com/1306991 | |
=end | |
require 'rubygems' | |
require 'roo' | |
if ARGV.size.zero? | |
$stdout.puts <<-EOF | |
USAGE: ruby #{$0} docs/ViviendaAguaCorriente2001.xls | |
EOF | |
exit 0 | |
end | |
oo = Excel.new(ARGV.first) | |
oo.default_sheet = oo.sheets.first | |
main_column = 'B' | |
max_rown_main_colum = oo.column(main_column).size | |
$stdout.puts "AREA; SI AGUA CORRIENTE; NO AGUA CORRIENTE; FUERA DE TERMINO" | |
1.upto(max_rown_main_colum-1) do |row_number| | |
content = oo.cell(row_number, main_column) | |
next if content.nil? | |
if content.include?('AREA #') | |
i = 0 | |
data = { | |
:area => content.split('#').last.strip, | |
:yes => 0.0, | |
:no => 0.0, | |
:outdated => 0.0 | |
} | |
until (max_rown_main_colum == row_number + i) || (!content.nil? && content.include?('Total')) | |
i = i + 1 | |
content = oo.cell(row_number + i, main_column) | |
next if content.nil? | |
data.update(:yes => oo.cell(row_number + i,'D')) if content.include?('Si') | |
data.update(:no => oo.cell(row_number + i,'D')) if content.include?('No') | |
data.update(:outdated => oo.cell(row_number + i,'D')) if content.include?('Fuera de término') | |
end | |
$stdout.puts data.values.join(';') | |
$stdout.flush | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment