Voice Over IP in UK - List of UK geographic area codes (was Re: Calling Sipgate from 3)

This is Interesting: Free IT Magazines  
Home > Archive > Voice Over IP in UK > January 2006 > List of UK geographic area codes (was Re: Calling Sipgate from 3)





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author List of UK geographic area codes (was Re: Calling Sipgate from 3)
Tim Clark

2006-01-19, 5:46 pm

I'm copying this to uk.telecom, with followups to there, since it's
rather strayed from its original subject, and is more relevant there
now.

A quick background. Discussion turned to choosing a UK geographic
area code, and BT's document at
http://www.downloads.bt.com/phonebook/pdf/UKCODESv2.pdf
where they list _all_ the names they associate with a geographic code
had been mentioned, and some examples extracted.

In article <43cfbba8$0$5001$db0fefd9@news.zen.co.uk>,
abuse@dopiaza.cabal.org.uk (Peter Corlett) writes:
> Tim Clark <Timothy.Clark@btinternet.com> wrote:
> [...]
>
> Here, have a text version of the useful bits of the PDF:
>
> #!/usr/bin/env perl
> use warnings;
> use strict;
> use LWP::Simple;
>
> my $url = 'http://www.downloads.bt.com/phonebook/pdf/UKCODESv2.pdf';
> my $cache = '/tmp/UKCODESv2.pdf';
>
> is_success(mirror($url, $cache)) or die "Could not download $url";
> open PIPE, "pdftotext $cache - |" or die "Can't open pipe: $!";
>
> while(<$fh> ) {
> chomp;
> foreach (split /(?<=\d)\s+(?!\d)/) {
> my($name, $code) = /^(.*?)\s+(0[12][\d\s]+)/ or next;
> $code =~ tr/0-9//cd;
> print "$code\t$name\n";
> }
> }


I had half sketched out in my mind some rather less succinct PERL to do
the job - though bizarrely by processing the output of pdf2ps instead of
pdftotext. I then discovered a text copy of the document that I had
stored in June 2005. (The text document I make oblique reference to.) I
couldn't remember how I'd created it, and wasted some time trying to
work that out. The results, below, might be useful to others.

Since the BT copyright on the document precludes posting useful decoded
versions of that document, Peter's PERL posting is a useful way for
those who want to get a version they can play with (e.g. to put into
spreadsheets, database, whatever) without the _poster_ breaking the
copyright. Of course anyone who runs it could find themselves breaking
the copyright conditions - but that's not likely to be a problem unless
they start distributing the output.

For others who want to get hold of it, but don't run Linux/Unix which
Peter's PERL relies on, here are some other methods I discovered
trying to work out what I'd done back in June to generate the text file
then. Some of these will work on other OSes such as Microsoft ones.

1. As Peter's PERL does: make use of pdftotext. It's included in many
Linux distributions, and part of the xpdf package which also works under
Microsoft OSes. Available at http://www.foolabs.com/xpdf/ . Process the
output of that with whatever you like to knock it into shape.

2. Since Google keep HTML versions of cached documents, find it by
googling for UKCODESv2.pdf and access the HTML version of it. There are
then quite a few options: save the HTML and process that, access it with
a text-only browser, or access it with a browser which will save the
document as a text file.

Ofcom have a similarly useful table available in PDF only (as far as I
can tell). "The National Telephone Numbering Plan Published by Ofcom, 11
August 2005". http://www.ofcom.org.uk/telecoms/ioi/numbers/261701.pdf

In Appendix B it gives a single useful name for each Geographic Area
code. As such, it's very useful in conjunction with CLI to see which
geographic area an incoming call from a UK geographic number wishes to
be associated with. It's been discussed in uk.telecom.voip recently,
with thoughts on how Asterisk could use it.

This Ofcom PDF file is not too amenable to the pdftotext approach - sure
all the text comes out, but the area code gets rather dislocated from
its corresponding name. That PDF does lend itself well to the other
approaches I mention above, including the strange one I used of pdf2ps
and processing that with Perl. A couple of weeks back, that's the
process I used to get this Appendix B data into a mysql database where
it's now being used as part of what I could pretentiously call a "Customer
Relationship Management" facility - were I into such newspeak.

PDF is fine for documents which are to be read by humans - but as a way
of distributing useful information, it is entirely unsuitable. It's a
real pain getting the info out of the document. I'm not sure why Ofcom
don't make the info in Appendix B of the National Telephone Numbering
Plan available in a form which can be used. Perhaps they do, and I
haven't found it on their site yet.

Between them, they are two very useful documents, in a totally
unsuitable format.

Ofcom is the appropriate body to name each code area (e.g. Warwick for
01926), though they take care to steer completely clear of issues like
defining boundaries. It's then entirely up to the individual operators
what they wish to do beyond that. Most operators won't bother
associating any additional name. BT, due to the way numbering developed,
will have a more extensive list of names they associate with each (e.g.
Kenilworth, Leamington Spa amongst others for 01926). They make that
information available, but restrict its reproduction. The result is the
curious mix between Ofcom information and BT information that we have
now.

Should anyone be interested, I plan to make available what info I can
on my own personal home site, in a more accessible form - once I've got
some simple permissions sorted - together with the tools for extracting
info too. I'll announce the URL here when it is uploaded.

--
Tim Clark
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com