source: freethepostcode.org/html/ruby/progress.rb @ 726

Last change on this file since 726 was 726, checked in by Dominic Hargreaves, 10 years ago

initial import

  • Property svn:executable set to *
File size: 882 bytes
Line 
1#!/usr/bin/ruby
2# Figure out our progress, based on the current list
3#
4# (Reports which inner parts we have coverage for)
5
6# To hold the list of postcode areas, and the inner numbers covered
7areas = {}
8infile = '/srv/www/freethepostcode.org/html/currentlist'
9puts "FreeThePostcode progress as of " + File.ctime(infile).to_s
10puts
11
12# Work through the current list
13File.open(infile) { |file|
14        file.each { |line| 
15                lat,long,inner,outer = line.chomp.split(' ')
16
17                re = /^([A-Z]+)(\d+)[A-Z]?$/
18                md = re.match(inner)
19                if md != nil then 
20                        area,number = md[1,2]
21
22                        if areas[area] == nil then
23                                areas[area] = {}
24                        end
25
26                        if areas[area][number] == nil then
27                                areas[area][number] = 1
28                        end
29                end
30        }
31}
32
33# Report what we found
34areas.keys.sort.each { |area|
35        numbers = []
36        areas[area].each { |number,junk|
37                numbers = numbers << number.to_i
38        }
39        puts area+" "+numbers.sort.join(",")
40}
Note: See TracBrowser for help on using the repository browser.