Skip to content

Instantly share code, notes, and snippets.

@kocolosk
Created November 29, 2009 03:59
Show Gist options
  • Save kocolosk/244781 to your computer and use it in GitHub Desktop.
Save kocolosk/244781 to your computer and use it in GitHub Desktop.
take MySQL RunLog text dump and save to sqlite
def upload_runlog():
import sqlite3 as sqlite
f = open('/tmp/runlog.txt')
db = sqlite.connect('/Users/kocolosk/data/analysis.db')
dbc = db.cursor()
for line in f:
data = line.split('|')[1:-1]
run = int(data[0].strip())
trigId = int(data[1].strip())
prescale = float(data[2].strip())
nevents = int(data[3].strip())
if trigId > 90000:
dbc.execute('''INSERT INTO runlog (run,trigId,prescale,nevents)
VALUES(?,?,?,?)''', (run,trigId,prescale,nevents))
db.commit()
dbc.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment