The Python program bdb_to_text.py
Here is the listing. The explanation will follow some months or weeks from now below, after the === bar.
#! /usr/bin/python import sys, bsddb, stationstring, re, string def main(): if len(sys.argv) != 2 or not re.search(r'\.bdb$', sys.argv): print "usage: bdb_to_text.py <bdb_file>" sys.exit() db_file = sys.argv txt_file = re.sub(r'bdb$', 'txt', db_file) db = bsddb.hashopen(db_file, 'r') print "reading", db_file f = open(txt_file, 'w') print "creating", txt_file ids = string.split(db['IDS']) count = 0 for id in ids: count = count + 1 if count % 1000 == 0: print count s = db[id] st = stationstring.new(s) f.write(st.to_text(id)) print count f.close() db.close() sys.exit() if __name__ == '__main__': main()
The analysis of this program will have to wait a fair while as I’m still finishing another step. It looks like it’s a well done library of utilities so I’ll likely leave it to the end.