3 from __future__
import print_function
7 from FWCore.PythonUtilities.LumiList
import LumiList
10 if __name__ ==
'__main__':
12 parser = optparse.OptionParser (
"Usage: %prog input.csv")
13 parser.add_option (
'--output', dest=
'output', type=
'string',
14 help=
'Save output to file OUTPUT')
15 parser.add_option (
'--runIndex', dest=
'runIndex', type=
'int',
17 help=
'column to be converted to run number (default %default)')
18 parser.add_option (
'--lumiIndex', dest=
'lumiIndex', type=
'int',
20 help=
'column to be converted to lumi section number (default %default)')
22 (options, args) = parser.parse_args()
24 raise RuntimeError(
"Must provide exactly one input file")
26 sepRE = re.compile (
r'[\s,;:]+')
28 events = open (args[0],
'r') 29 runIndex, lumiIndex = options.runIndex, options.lumiIndex 30 minPieces = max (runIndex, lumiIndex) + 1 32 pieces = sepRE.split (line.strip())
33 if len (pieces) < minPieces:
36 run, lumi =
int( pieces[runIndex] ),
int( pieces[lumiIndex] )
39 runLumiDict.setdefault (run, []).append (lumi)
40 jsonList = LumiList (runsAndLumis = runLumiDict)
42 jsonList.writeJSON (options.output)
S & print(S &os, JobReport::InputFile const &f)