tspy.data_structures.io.TimeSeriesWriter module

class tspy.data_structures.io.TimeSeriesWriter.TimeSeriesWriter(tsc, j_time_series_writer)

Bases: object

Builder pattern used for writing a time-series to an outside data-source

Notes

A time-series-writer has a few components:
  • observations: the in-memory observations to write to an outside data-source

  • options: key-value string pair in map of options to be used in writing

  • value-encoder: function to encode a value to a String, by default __str__ is used

This class works as follows:
  • builds a blank time-series-writer that only contains observations

  • set options and value-encoder (optional)

  • save to data-source (using a time-series-write-format) given options and value-encoder

Methods

csv(path)

save as csv

encode_value(value_encoder)

set function to encode a value to a string when writing

object_file(path)

save as object-file

option(key, value)

set an option for this time-series-writer

options(**kwargs)

set multiple options for this time-series-writer

save(time_series_write_format)

save to a user-defined time-series-write-format

csv(path)

save as csv

Parameters
pathstr

file path to save to

encode_value(value_encoder)

set function to encode a value to a string when writing

Parameters
value_encoderfunc

function to encode a value to a string when writing

Returns
TimeSeriesWriter

this time-series-writer

object_file(path)

save as object-file

Parameters
pathstr

file path to save to

option(key, value)

set an option for this time-series-writer

Parameters
keystr

option key

valueAny

option value

Returns
TimeSeriesWriter

this time-series-writer

options(**kwargs)

set multiple options for this time-series-writer

Parameters
kwargskey-value varargs

key-value options as varargs

Returns
TimeSeriesWriter

this time-series-writer

save(time_series_write_format)

save to a user-defined time-series-write-format

Parameters
time_series_write_formatTimeSeriesWriteFormat

the time-series write format