LSSTApplications
10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
datarel
11.0.rc2+12
python
lsst
datarel
csvFileWriter.py
Go to the documentation of this file.
1
import
gzip
2
import
re
3
import
lsst.daf.base
as
dafBase
4
5
class
CsvFileWriter
(object):
6
def
__init__
(self, path, overwrite=True, compress=True):
7
if
compress:
8
self.
f
= gzip.open(path +
".gz"
,
"w"
if
overwrite
else
"a"
)
9
else
:
10
self.
f
= open(path,
"w"
if
overwrite
else
"a"
)
11
12
def
__del__
(self):
13
self.f.close()
14
15
def
flush
(self):
16
self.f.flush()
17
18
def
quote
(self, value):
19
if
value
is
None
:
20
return
'\N'
21
if
isinstance(value, float):
22
return
"%.17g"
% (value,)
23
if
isinstance(value, str):
24
value = re.sub(
r'"'
,
r'\"'
, value)
25
return
'"'
+ value.strip() +
'"'
26
if
isinstance(value,
dafBase.DateTime
):
27
value = value.toString()
28
return
'"'
+ value[0:10] +
' '
+ value[11:19] +
'"'
29
return
str(value)
30
31
def
write
(self, *fields):
32
print
>>self.
f
,
","
.join([self.
quote
(field)
for
field
in
fields])
lsst.datarel.csvFileWriter.CsvFileWriter.flush
def flush
Definition:
csvFileWriter.py:15
lsst::daf::base::DateTime
Class for handling dates/times, including MJD, UTC, and TAI.
Definition:
DateTime.h:58
lsst.datarel.csvFileWriter.CsvFileWriter
Definition:
csvFileWriter.py:5
lsst.datarel.csvFileWriter.CsvFileWriter.__init__
def __init__
Definition:
csvFileWriter.py:6
lsst.datarel.csvFileWriter.CsvFileWriter.write
def write
Definition:
csvFileWriter.py:31
lsst.datarel.csvFileWriter.CsvFileWriter.quote
def quote
Definition:
csvFileWriter.py:18
lsst.datarel.csvFileWriter.CsvFileWriter.f
f
Definition:
csvFileWriter.py:8
lsst::daf::base
Definition:
Formatter.h:67
lsst.datarel.csvFileWriter.CsvFileWriter.__del__
def __del__
Definition:
csvFileWriter.py:12
Generated on Wed Sep 16 2015 13:35:29 for LSSTApplications by
1.8.5