Skip to content

Instantly share code, notes, and snippets.

@rangerscience
Created June 18, 2011 04:19
Show Gist options
  • Save rangerscience/1032799 to your computer and use it in GitHub Desktop.
Save rangerscience/1032799 to your computer and use it in GitHub Desktop.
Dir.glob('script/parsing/raw-data/*.ets').each do |filename|
puts "Reading #{filename}..."
raw = File.open(filename, 'r')
section_data = Array.new
(0..9).each do |d|
puts "Selecting: 00#{d.to_s}"
lines = raw.select{|line| /^00#{d.to_s}/.match(line)}
puts lines
data = parse_section(lines)
next if data.nil?
section_data.push data unless data.nil?
end
(10..99).each do |d|
lines = raw.select{|line| /^0#{d.to_s}/.match(line)}
data = parse_section(lines)
next if data.nil?
section_data.push data unless data.nil?
end
(100..999).each do |d|
lines = raw.select{|line| /^#{d.to_s}/.match(line)}
data = parse_section(lines)
next if data.nil?
section_data.push data unless data.nil?
end
make_data "#{File.basename(filename, '.ets')}", section_data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment