Skip to content

Instantly share code, notes, and snippets.

@natevw
Created September 4, 2019 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natevw/3ddfe7aef454c345f68464048ad52ee2 to your computer and use it in GitHub Desktop.
Save natevw/3ddfe7aef454c345f68464048ad52ee2 to your computer and use it in GitHub Desktop.
#! /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