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