コード例 #1
0
ファイル: __init__.py プロジェクト: GunioRobot/dynts
    def __call__(self, ts, filename = None, title = None, raw = False, **kwargs):
        '''Dump the timeseries to an xls representation.
This function requires the python xlwt__ package.
    
__ http://pypi.python.org/pypi/xlwt'''
        try:
            import xlwt
        except ImportError:
            raise FormattingException('To save the timeseries as a spreadsheet, the xlwt python library is required.')
        
        
        if isinstance(filename,xlwt.Workbook):
            wb = filename
        else:
            wb = xlwt.Workbook()
        title = title or ts.name
        stream = StreamIO()
        sheet = wb.add_sheet(title)
        for i,row in enumerate(tsiterator(ts)):
            for j,col in enumerate(row):
                sheet.write(i,j,str(col))
        
        if raw:
            return wb
        else:
            stream = StreamIO()
            wb.save(stream)
            return stream.getvalue()
コード例 #2
0
    def __call__(self, ts, filename=None, title=None, raw=False, **kwargs):
        '''Dump the timeseries to an xls representation.
This function requires the python xlwt__ package.

__ http://pypi.python.org/pypi/xlwt'''
        try:
            import xlwt
        except ImportError:
            raise FormattingException(
                'To save the timeseries as a spreadsheet, the xlwt python library is required.'
            )

        if isinstance(filename, xlwt.Workbook):
            wb = filename
        else:
            wb = xlwt.Workbook()
        title = title or ts.name
        stream = StreamIO()
        sheet = wb.add_sheet(title)
        for i, row in enumerate(tsiterator(ts)):
            for j, col in enumerate(row):
                sheet.write(i, j, str(col))

        if raw:
            return wb
        else:
            stream = StreamIO()
            wb.save(stream)
            return stream.getvalue()
コード例 #3
0
ファイル: __init__.py プロジェクト: GunioRobot/dynts
 def __call__(self, ts, filename = None, **kwargs):
     '''Returns CSV representation of a :class:`dynts.TimeSeries`.'''
     stream = StreamIO()
     _csv = csv.writer(stream)
 
     for row in tsiterator(ts):
         _csv.writerow(row)
 
     return stream.getvalue()
コード例 #4
0
    def __call__(self, ts, filename=None, **kwargs):
        '''Returns CSV representation of a :class:`dynts.TimeSeries`.'''
        stream = StreamIO()
        _csv = csv.writer(stream)

        for row in tsiterator(ts):
            _csv.writerow(row)

        return stream.getvalue()