Script to gather ham callsign statistics for https://ham.stackexchange.com/questions/15262/what-fraction-of-2x2-usa-call-signs-are-vanity-calls
#! /usr/bin/python | |
import re | |
import sys | |
callsign_fmt = sys.argv[1] if len(sys.argv) > 1 else '2x2' | |
normal_tally = 0 | |
vanity_tally = 0 | |
with open("l_amat/HD.dat", 'r') as file: | |
callsign_re = r'^[A-Z]{%s}[0-9][A-Z]{%s}$' % tuple(callsign_fmt.split('x')) | |
for line in file: | |
callsign, status, service = line.split('|')[4:7] | |
if status != 'A': | |
continue | |
if re.match(callsign_re, callsign): | |
if service == 'HA': | |
normal_tally += 1 | |
elif service == 'HV': | |
vanity_tally += 1 | |
else: | |
assert False, "Unknown service code %s for %s" % (service, callsign) | |
total_active = normal_tally + vanity_tally | |
print "Found %s total active %s licenses" % (total_active, callsign_fmt) | |
if total_active > 0: | |
print "Normal: %s" % (normal_tally,) | |
print "Vanity: %s => %0.1f%%" % (vanity_tally, (100.0 * vanity_tally) / total_active) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment