# JSON Time Series
[![Documentation Status](https://readthedocs.org/projects/json-timeseries-py/badge/?version=latest)](https://json-timeseries-py.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/json-timeseries.svg)](https://badge.fury.io/py/json-timeseries)
[JSON Time Series](https://docs.eagle.io/en/latest/reference/historic/jts.html) (JTS specification) handling Python library - Time Series data construction, manipulation and serialisation.
## Installation
```shell
pip install json-timeseries
```
Import or require module
```python
from json_timeseries import TsRecord, TimeSeries, JtsDocument
```
## Usage
```python
from json_timeseries import TsRecord, TimeSeries, JtsDocument
from datetime import datetime
# Create Time Series
timeseries1 = TimeSeries(identifier='series_1', name='Series 1', data_type='NUMBER',
records=[
TsRecord(**{"timestamp": datetime.now(), "value": '1.23', "quality": 192, "annotation": 'comment'}),
TsRecord(**{"timestamp": datetime.now(), "value": '2.34', "quality": 245, "annotation": 'comment number 2'})])
timeseries2 = TimeSeries(identifier='series_2', name='Series 2', data_type='NUMBER', units="C",
records=TsRecord(timestamp=datetime.now(), value=1.11, quality=111, annotation="comment ts2 111")
)
# Add record(s)
timeseries1.insert(TsRecord(**{ timestamp: datetime.now(), value: 30 }))
# Output in JSON Time Series document format
jts_doc = JtsDocument([timeseries1, timeseries2])
json_str = jts_doc.toJSONString()
````
## TimeSeries
`TimeSeries` is a class for constructing and manipulating a single dataset.
```python
from json_timeseries import TsRecord, TimeSeries
from datetime import datetime
time_series = TimeSeries(identifier='series_2', name='Series 2', data_type='NUMBER', units="m/s",
records=TsRecord(timestamp=datetime.now(), value=1.11, quality=0, annotation="example comment")
)
```
### Options
Optionally provide configuration used for certain output formats such as JTS Document.
- `data_type`: data type of record **value** attribute. `NUMBER | TEXT | TIME | COORDINATES`
- `id`: string or number to uniquely identify the series to use instead of the automatically assigned id.
- `name`: string
- `units`: string
- `records`: list of data records
Alternatively set later:
```python
time_series.data_type = 'NUMBER'
time_series.id = 'Series_1'
time_series.name = 'My Series'
time_series.units = 'm/s'
```
## TsRecord
`TsRecord` is a class for constructing and manipulating a single record.
```python
from json_timeseries import TsRecord
from datetime import datetime
ts_record1 = TsRecord(timestamp=datetime.now(), value=1.11, quality=0, annotation="example comment")
# Or as dict of parameters using ** operator
ts_record2 = TsRecord(**{"timestamp": datetime.now(), "value": 1.11, "quality": 0, "annotation": 'example comment'})
```
### Record attributes
Records require a timestamp and at least one attribute: value, quality or annotation
- `timestamp`: date object. Type of datetime. e.g.`datetime.now()`
- `value` *(optional)*: number, string, date, null
- `quality` *(optional)*: number (quality code) associated with value
- `annotation` (optional): string description or comment related to the record
### Methods
See [full documentation](https://json-timeseries-py.readthedocs.io).
### Properties
See [full documentation](https://json-timeseries-py.readthedocs.io).
## JTS Document
`JtsDocument` is a class for outputting `TimeSeries` in
[JSON Time Series](https://docs.eagle.io/en/latest/reference/historic/jts.html) document format.
```python
# Create a JTS Document from one or more timeseries
jts_document = JtsDocument(series=[timeseries1, timeseries2])
# Output series in JTS Document format
json_str = jts_document.toJSONString()
```
### Options
- `series`: array of `TimeSeries` to include in JTS Document
### Methods
See [full documentation](https://json-timeseries-py.readthedocs.io).
### Properties
See [full documentation](https://json-timeseries-py.readthedocs.io).
## License
MIT
Raw data
{
"_id": null,
"home_page": "https://github.com/slaxor505/json-timeseries-py",
"name": "json-timeseries",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "json, timeseries, iot, jts",
"author": "Slava Pisarevskiy",
"author_email": "slava@plantbook.io",
"download_url": "https://files.pythonhosted.org/packages/d3/54/05a8c8bf9bc8303a19dbec4a28f833bc47c7424832243b5e9f051bc02bb0/json_timeseries-0.1.7.tar.gz",
"platform": null,
"description": "# JSON Time Series\n\n[![Documentation Status](https://readthedocs.org/projects/json-timeseries-py/badge/?version=latest)](https://json-timeseries-py.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/json-timeseries.svg)](https://badge.fury.io/py/json-timeseries)\n\n[JSON Time Series](https://docs.eagle.io/en/latest/reference/historic/jts.html) (JTS specification) handling Python library - Time Series data construction, manipulation and serialisation.\n\n## Installation\n\n```shell\npip install json-timeseries\n```\n\nImport or require module\n```python\nfrom json_timeseries import TsRecord, TimeSeries, JtsDocument\n```\n\n## Usage\n\n```python\nfrom json_timeseries import TsRecord, TimeSeries, JtsDocument\nfrom datetime import datetime\n\n# Create Time Series\ntimeseries1 = TimeSeries(identifier='series_1', name='Series 1', data_type='NUMBER', \n records=[\n TsRecord(**{\"timestamp\": datetime.now(), \"value\": '1.23', \"quality\": 192, \"annotation\": 'comment'}),\n TsRecord(**{\"timestamp\": datetime.now(), \"value\": '2.34', \"quality\": 245, \"annotation\": 'comment number 2'})])\n\ntimeseries2 = TimeSeries(identifier='series_2', name='Series 2', data_type='NUMBER', units=\"C\", \n records=TsRecord(timestamp=datetime.now(), value=1.11, quality=111, annotation=\"comment ts2 111\")\n )\n\n# Add record(s)\ntimeseries1.insert(TsRecord(**{ timestamp: datetime.now(), value: 30 }))\n\n# Output in JSON Time Series document format\njts_doc = JtsDocument([timeseries1, timeseries2])\njson_str = jts_doc.toJSONString()\n````\n\n## TimeSeries\n`TimeSeries` is a class for constructing and manipulating a single dataset.\n\n```python\nfrom json_timeseries import TsRecord, TimeSeries\nfrom datetime import datetime\n\ntime_series = TimeSeries(identifier='series_2', name='Series 2', data_type='NUMBER', units=\"m/s\", \n records=TsRecord(timestamp=datetime.now(), value=1.11, quality=0, annotation=\"example comment\")\n )\n```\n### Options\nOptionally provide configuration used for certain output formats such as JTS Document. \n- `data_type`: data type of record **value** attribute. `NUMBER | TEXT | TIME | COORDINATES`\n- `id`: string or number to uniquely identify the series to use instead of the automatically assigned id.\n- `name`: string\n- `units`: string\n- `records`: list of data records\n \nAlternatively set later:\n```python\ntime_series.data_type = 'NUMBER'\ntime_series.id = 'Series_1'\ntime_series.name = 'My Series'\ntime_series.units = 'm/s'\n```\n\n## TsRecord\n`TsRecord` is a class for constructing and manipulating a single record.\n\n```python\nfrom json_timeseries import TsRecord\nfrom datetime import datetime\n\nts_record1 = TsRecord(timestamp=datetime.now(), value=1.11, quality=0, annotation=\"example comment\")\n# Or as dict of parameters using ** operator\nts_record2 = TsRecord(**{\"timestamp\": datetime.now(), \"value\": 1.11, \"quality\": 0, \"annotation\": 'example comment'})\n```\n### Record attributes\nRecords require a timestamp and at least one attribute: value, quality or annotation\n- `timestamp`: date object. Type of datetime. e.g.`datetime.now()`\n- `value` *(optional)*: number, string, date, null\n- `quality` *(optional)*: number (quality code) associated with value\n- `annotation` (optional): string description or comment related to the record\n\n### Methods \n\nSee [full documentation](https://json-timeseries-py.readthedocs.io).\n\n### Properties\n\nSee [full documentation](https://json-timeseries-py.readthedocs.io).\n\n\n\n## JTS Document\n\n`JtsDocument` is a class for outputting `TimeSeries` in \n[JSON Time Series](https://docs.eagle.io/en/latest/reference/historic/jts.html) document format.\n\n\n```python\n# Create a JTS Document from one or more timeseries\njts_document = JtsDocument(series=[timeseries1, timeseries2])\n# Output series in JTS Document format\njson_str = jts_document.toJSONString()\n```\n\n### Options\n\n- `series`: array of `TimeSeries` to include in JTS Document\n\n### Methods \n\nSee [full documentation](https://json-timeseries-py.readthedocs.io).\n\n### Properties\n\nSee [full documentation](https://json-timeseries-py.readthedocs.io).\n\n## License\nMIT\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "JSON-TimeSeries (JTS specification) handling library",
"version": "0.1.7",
"project_urls": {
"Documentation": "https://json-timeseries-py.readthedocs.io",
"Homepage": "https://github.com/slaxor505/json-timeseries-py",
"Source": "https://github.com/slaxor505/json-timeseries-py",
"Specification": "https://docs.eagle.io/en/latest/reference/historic/jts.html"
},
"split_keywords": [
"json",
" timeseries",
" iot",
" jts"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "62a408f3c790a722e76bd70cd6cefa07919de6c627b0794d417f648abcb29677",
"md5": "2b22c7a0dc5b2efde49029c83275df37",
"sha256": "6af2d7a31dfef4fa8e8417689003f6a32a5b5a4f0998cbc55d21eea6e0ce5e55"
},
"downloads": -1,
"filename": "json_timeseries-0.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2b22c7a0dc5b2efde49029c83275df37",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9563,
"upload_time": "2024-09-04T12:30:58",
"upload_time_iso_8601": "2024-09-04T12:30:58.292437Z",
"url": "https://files.pythonhosted.org/packages/62/a4/08f3c790a722e76bd70cd6cefa07919de6c627b0794d417f648abcb29677/json_timeseries-0.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d35405a8c8bf9bc8303a19dbec4a28f833bc47c7424832243b5e9f051bc02bb0",
"md5": "0454a680bbf5693da91da23db37d83c0",
"sha256": "12addeb14d8a374fcef7ab05698b9cc43880e707c29bc83103d80414e29b602c"
},
"downloads": -1,
"filename": "json_timeseries-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "0454a680bbf5693da91da23db37d83c0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 13786,
"upload_time": "2024-09-04T12:31:00",
"upload_time_iso_8601": "2024-09-04T12:31:00.234941Z",
"url": "https://files.pythonhosted.org/packages/d3/54/05a8c8bf9bc8303a19dbec4a28f833bc47c7424832243b5e9f051bc02bb0/json_timeseries-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-04 12:31:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "slaxor505",
"github_project": "json-timeseries-py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "json-timeseries"
}