Created
November 29, 2009 03:59
-
-
Save kocolosk/244781 to your computer and use it in GitHub Desktop.
take MySQL RunLog text dump and save to sqlite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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