Main Page
Namespaces
Classes
Package Documentation
RecoLuminosity
LumiDB
python
csvSelectionParser.py
Go to the documentation of this file.
1
from
__future__
import
print_function
2
import
csv
3
def
is_intstr
(s):
4
try
:
5
int
(s)
6
return
True
7
except
ValueError:
8
return
False
9
class
csvSelectionParser
(
object
):
10
def
__init__
(self,filename):
11
self.
__result
={}
12
self.
__strresult
={}
13
self.
__filename
=filename
14
csvReader=csv.reader(open(filename),delimiter=
','
)
15
for
row
in
csvReader:
16
field0=
str
(row[0]).
strip
()
17
try
:
18
field1=
str
(row[1]).
strip
()
19
except
Exception
as
e:
20
field1=
'1'
# for list with run number only, fake lsnum
21
if
not
is_intstr
(field0)
or
not
is_intstr
(field1):
22
continue
23
runnumber=
int
(field0)
24
lsnumber=
int
(field1)
25
if
runnumber
in
self.
__result
:
26
self.
__result
[runnumber].
append
(lsnumber)
27
else
:
28
self.
__result
[runnumber]=[lsnumber]
29
for
k,lsvalues
in
self.__result.items():
30
lsvalues.sort()
31
self.
__strresult
[k]=[
str
(x)
for
x
in
lsvalues]
32
def
runs
(self):
33
return
self.__result.keys()
34
def
runsandls
(self):
35
'''return {run:lslist}
36
'''
37
return
self.
__result
38
def
runsandlsStr
(self):
39
'''return {'run':lslist}
40
'''
41
return
self.
__strresult
42
def
numruns
(self):
43
return
len(self.
__result
)
44
def
numls
(self,run):
45
return
len(self.
__result
[run])
46
47
if
__name__ ==
'__main__'
:
48
result={}
49
#filename='../test/lumi_by_LS_all.csv'
50
filename=
'../test/newruns.csv'
51
s=
csvSelectionParser
(filename)
52
print
(
'runs : '
,s.runs())
53
print
(
'full result : '
,s.runsandls())
54
print
(
'str result : '
,s.runsandlsStr())
55
print
(
'num runs : '
,s.numruns())
56
#print 'numls in run : ',s.numls(135175)
57
csvSelectionParser.csvSelectionParser.__init__
def __init__(self, filename)
Definition:
csvSelectionParser.py:10
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition:
JobReport.cc:66
csvSelectionParser.is_intstr
def is_intstr(s)
Definition:
csvSelectionParser.py:3
csvSelectionParser.csvSelectionParser.__filename
__filename
Definition:
csvSelectionParser.py:13
csvSelectionParser.csvSelectionParser.runsandlsStr
def runsandlsStr(self)
Definition:
csvSelectionParser.py:38
createfilelist.int
int
Definition:
createfilelist.py:10
csvSelectionParser.csvSelectionParser.numruns
def numruns(self)
Definition:
csvSelectionParser.py:42
csvSelectionParser.csvSelectionParser.numls
def numls(self, run)
Definition:
csvSelectionParser.py:44
mps_setup.append
append
Definition:
mps_setup.py:84
csvSelectionParser.csvSelectionParser.runs
def runs(self)
Definition:
csvSelectionParser.py:32
digitizers_cfi.strip
strip
Definition:
digitizers_cfi.py:19
csvSelectionParser.csvSelectionParser
Definition:
csvSelectionParser.py:9
csvSelectionParser.csvSelectionParser.__result
__result
Definition:
csvSelectionParser.py:11
csvSelectionParser.csvSelectionParser.__strresult
__strresult
Definition:
csvSelectionParser.py:12
str
#define str(s)
Definition:
TestProcessor.cc:47
csvSelectionParser.csvSelectionParser.runsandls
def runsandls(self)
Definition:
csvSelectionParser.py:34
resolutioncreator_cfi.object
object
Definition:
resolutioncreator_cfi.py:4
Generated for CMSSW Reference Manual by
1.8.11