2011-05-26 15:47:32 -07:00
|
|
|
import sys
|
|
|
|
import numpy as np
|
|
|
|
import sqlite3
|
|
|
|
from optparse import OptionParser
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
parser = OptionParser(usage = "usage: %s <input text file> <output db file>")
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
if len(args) != 2:
|
|
|
|
parser.print_usage()
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
data_file_name, sql_file_name = args
|
|
|
|
|
|
|
|
data = np.loadtxt(data_file_name)
|
|
|
|
|
|
|
|
con = sqlite3.connect(sql_file_name)
|
|
|
|
cur = con.cursor()
|
|
|
|
cur.execute('DROP TABLE IF EXISTS results')
|
2011-05-27 16:18:44 -07:00
|
|
|
cur.execute('CREATE TABLE results (res INTEGER, ord INTEGER, ep INTEGER, qlin FLOAT, err FLOAT, final FLOAT, exact FLOAT, time FLOAT)')
|
|
|
|
cur.executemany("insert into results values(?,?,?,?,?,?,?,?)", data)
|
2011-05-26 15:47:32 -07:00
|
|
|
con.commit()
|
|
|
|
cur.close()
|
|
|
|
con.close()
|