LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
datarel
11.0+1
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:
Utils.h:41
lsst.datarel.csvFileWriter.CsvFileWriter.__del__
def __del__
Definition:
csvFileWriter.py:12
Generated on Thu Sep 24 2015 02:29:19 for LSSTApplications by
1.8.5