I have some python scripts to read logs. I want to transfer the logs read from Python to CINT. Here are the detail story.
Data file (something like these):
# Gamma 1: E_γ = 0.847 MeV
# Gamma 1: E_γ = 1.238 MeV
C1C1-PH: [ 61, 272, 124], [273, 3840]
C1C2-PH: [ 79, 121, 88], [150, 3842], [1450.37, 6.33774], [2359.08, 5.25428], [3418.48, 4.87569]
C1C3-PH: [100, 128, 111], [250, 3833], [1478.59, 6.28460], [2392.18, 4.50688], [3457.03, 5.22970]
Python script to handle them:
def valid(a):
if len(a)>0 and a[0] != "#": return True
def readrlog(fn):
ss = [l.strip() for l in open(fn,"r").readlines()]
records = {}
for aa in filter(valid, ss):
key,v = aa.split(":")
try: records[key] = eval(v)
except: print "Invalid record:",key,'--',v
return records
logs = readrlog("myfile.log")
I want to use the result “logs” in CINT. How to implement this? TPythong::Bind(…)?
Please give me some hints. Thanks!