Advertisement
Guest User

Untitled

a guest
Oct 29th, 2020
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import pyodbc
  2.  
  3. dbfile = 'C:/Logs/N6ML/dxkmega.mdb'
  4.  
  5. cnx = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=%s' % (dbfile))
  6. cursor = cnx.cursor().execute("select Call,[Band] from QSOs;")
  7.  
  8. by_call = {}
  9.  
  10. for call, band in cursor.fetchall():
  11.     by_call.setdefault(call, set())
  12.     by_call[call].add(band)
  13.  
  14. for call, bands in by_call.items():
  15.     if len(bands) >= 9:
  16.         srt = sorted(bands, key=lambda x: int(x[:-1]))
  17.         print('%s has been worked on %d bands: %s' %
  18.               (call, len(bands), ' '.join(srt)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement