GIStemp STEP1_bdb_to_text

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[1]):
        print "usage: bdb_to_text.py <bdb_file>"
        sys.exit()
    db_file = sys.argv[1]
    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.

Advertisements

About E.M.Smith

A technical managerial sort interested in things from Stonehenge to computer science. My present "hot buttons' are the mythology of Climate Change and ancient metrology; but things change...
This entry was posted in GISStemp Technical and Source Code and tagged , , , , , . Bookmark the permalink.

2 Responses to GIStemp STEP1_bdb_to_text

  1. Dan Hughes says:

    E. M. I have sent you e-mail about my attempt to get GISSTemp operational.

    I need some assistance with Python installation for STEP1.

    Thanks

    Dan

  2. E.M.Smith says:

    I’ve responded to the email (and to the other posting on the other page here).

    Is your problem in the C libraries or in the Python install or?

Comments are closed.