Created
September 4, 2019 22:33
-
-
Save natevw/3ddfe7aef454c345f68464048ad52ee2 to your computer and use it in GitHub Desktop.
Script to gather ham callsign statistics for https://ham.stackexchange.com/questions/15262/what-fraction-of-2x2-usa-call-signs-are-vanity-calls
This file contains hidden or 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
#! /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