Name | nemwriter JSON |
Version |
0.4.6
JSON |
| download |
home_page | None |
Summary | nemwriter |
upload_time | 2023-12-14 23:37:34 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
energy
nem12
nem13
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# nem-writer
[![PyPI version](https://badge.fury.io/py/nemwriter.svg)](https://badge.fury.io/py/nemwriter) [![Build Status](https://travis-ci.org/aguinane/nem-writer.svg?branch=master)](https://travis-ci.org/aguinane/nem-writer) [![Coverage Status](https://coveralls.io/repos/github/aguinane/nem-writer/badge.svg?branch=master)](https://coveralls.io/github/aguinane/nem-writer?branch=master)
Write meter readings to AEMO NEM12 (interval metering data) and NEM13 (accumulated metering data) data files
## Accumulated Data (NEM13)
```python
from datetime import datetime
from nemwriter import NEM13
m = NEM13(to_participant='123')
ch = m.add_reading(nmi='123',
nmi_configuration='E1B1B2',
register_id='1',
nmi_suffix='E1',
previous_read=412,
previous_read_date=datetime(2017,1,1),
previous_quality_method='A',
current_read=512,
current_read_date=datetime(2017,2,1),
current_quality_method='A',
quantity=100,
uom='kWh'
)
output = m.output_csv(file_path='output.csv')
```
Will output:
```
100,NEM13,201701010101,,123
250,123,E1B1B2,1,E1,,,E,412,201701010000,A,,,512,201702010000,A,,,100,kWh,,,
900
```
## Interval Data (NEM12)
```python
from datetime import datetime
from nemwriter import NEM12
m = NEM12(to_participant='123')
readings = [
# read end, read value, quality method, event code, event desc
[datetime(2004, 4, 18, 0, 30), 10.1, 'A', 79, 'Power Outage Alarm'],
[datetime(2004, 4, 18, 1, 0), 11.2, 'A'],
[datetime(2004, 4, 18, 1, 30), 12.3, 'A'],
[datetime(2004, 4, 18, 2, 0), 13.4, 'A'],
]
ch = m.add_readings(nmi='123',
nmi_configuration='E1B1B2',
nmi_suffix='E1', uom='kWh',
readings=readings)
output = m.output_csv(file_path='output.csv')
```
Will output:
```
100,NEM12,201701010101,,123
200,123,E1B1B2,,E1,,,kWh,30,
300,20040418,10.1,11.2,12.3,13.4,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,V,,,,
400,1,1,A,79,Power Outage Alarm
400,2,48,A,,
900
```
Alternatively, save as a compressed csv in a zip file.
```python
output = m.output_zip(file_path='output.zip')
```
### From Pandas DataFrame
If you create a pandas DataFrame, for example:
```python
num_intervals = 288
index = [datetime(2004, 4, 1) + timedelta(minutes=5*x) for x in range(1,num_intervals+1)]
e1 = [randrange(1,10) for x in range(1,num_intervals+1)]
e2 = [randrange(1,5) for x in range(1,num_intervals+1)]
s1 = pd.Series(data=e1, index=index, name="E1")
s2 = pd.Series(data=e2, index=index, name="E2")
df=pd.concat([s1,s2],axis=1)
print(df)
```
```
E1 E2
2004-04-01 00:05:00 2 3
2004-04-01 00:10:00 8 3
2004-04-01 00:15:00 7 2
2004-04-01 00:20:00 4 3
2004-04-01 00:25:00 3 4
... .. ..
2004-04-01 23:40:00 9 2
2004-04-01 23:45:00 1 1
2004-04-01 23:50:00 6 2
2004-04-01 23:55:00 7 1
2004-04-01 00:00:00 4 2
```
You can easily output the dataframe to a NEM12 file:
```python
m = NEM12(to_participant='123')
m.add_dataframe(nmi='123', interval=5, df=df, uoms={'E1': 'kWh', 'E2': 'kWh'})
output = m.output_csv(file_path='output.csv')
```
If your DataFrame has a `Quality` and `EventDesc` column, they will also be handled appropriately.
Raw data
{
"_id": null,
"home_page": null,
"name": "nemwriter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "energy,NEM12,NEM13",
"author": null,
"author_email": "Alex Guinman <alex@guinman.id.au>",
"download_url": "https://files.pythonhosted.org/packages/9a/ae/586d048681a504cf8e5be4af5f5f04e703f738be3ed27e1a0f3306ae5276/nemwriter-0.4.6.tar.gz",
"platform": null,
"description": "# nem-writer\n\n[![PyPI version](https://badge.fury.io/py/nemwriter.svg)](https://badge.fury.io/py/nemwriter) [![Build Status](https://travis-ci.org/aguinane/nem-writer.svg?branch=master)](https://travis-ci.org/aguinane/nem-writer) [![Coverage Status](https://coveralls.io/repos/github/aguinane/nem-writer/badge.svg?branch=master)](https://coveralls.io/github/aguinane/nem-writer?branch=master)\n\nWrite meter readings to AEMO NEM12 (interval metering data) and NEM13 (accumulated metering data) data files\n\n## Accumulated Data (NEM13)\n\n```python\nfrom datetime import datetime\nfrom nemwriter import NEM13\n\nm = NEM13(to_participant='123')\nch = m.add_reading(nmi='123',\n nmi_configuration='E1B1B2',\n register_id='1',\n nmi_suffix='E1',\n previous_read=412,\n previous_read_date=datetime(2017,1,1),\n previous_quality_method='A',\n current_read=512,\n current_read_date=datetime(2017,2,1),\n current_quality_method='A',\n quantity=100,\n uom='kWh'\n )\noutput = m.output_csv(file_path='output.csv')\n```\n\nWill output:\n```\n100,NEM13,201701010101,,123\n250,123,E1B1B2,1,E1,,,E,412,201701010000,A,,,512,201702010000,A,,,100,kWh,,,\n900\n```\n\n## Interval Data (NEM12)\n\n```python\nfrom datetime import datetime\nfrom nemwriter import NEM12\n\nm = NEM12(to_participant='123')\nreadings = [\n # read end, read value, quality method, event code, event desc\n [datetime(2004, 4, 18, 0, 30), 10.1, 'A', 79, 'Power Outage Alarm'],\n [datetime(2004, 4, 18, 1, 0), 11.2, 'A'],\n [datetime(2004, 4, 18, 1, 30), 12.3, 'A'],\n [datetime(2004, 4, 18, 2, 0), 13.4, 'A'],\n]\n\nch = m.add_readings(nmi='123',\n nmi_configuration='E1B1B2',\n nmi_suffix='E1', uom='kWh',\n readings=readings)\noutput = m.output_csv(file_path='output.csv')\n```\n\nWill output:\n```\n100,NEM12,201701010101,,123\n200,123,E1B1B2,,E1,,,kWh,30,\n300,20040418,10.1,11.2,12.3,13.4,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,V,,,,\n400,1,1,A,79,Power Outage Alarm\n400,2,48,A,,\n900\n\n```\n\nAlternatively, save as a compressed csv in a zip file.\n```python\noutput = m.output_zip(file_path='output.zip')\n```\n\n### From Pandas DataFrame\n\nIf you create a pandas DataFrame, for example:\n\n```python\nnum_intervals = 288\nindex = [datetime(2004, 4, 1) + timedelta(minutes=5*x) for x in range(1,num_intervals+1)]\ne1 = [randrange(1,10) for x in range(1,num_intervals+1)]\ne2 = [randrange(1,5) for x in range(1,num_intervals+1)]\ns1 = pd.Series(data=e1, index=index, name=\"E1\")\ns2 = pd.Series(data=e2, index=index, name=\"E2\")\ndf=pd.concat([s1,s2],axis=1)\nprint(df)\n```\n\n```\n E1 E2\n2004-04-01 00:05:00 2 3\n2004-04-01 00:10:00 8 3\n2004-04-01 00:15:00 7 2\n2004-04-01 00:20:00 4 3\n2004-04-01 00:25:00 3 4\n... .. ..\n2004-04-01 23:40:00 9 2\n2004-04-01 23:45:00 1 1\n2004-04-01 23:50:00 6 2\n2004-04-01 23:55:00 7 1\n2004-04-01 00:00:00 4 2\n```\n\nYou can easily output the dataframe to a NEM12 file:\n```python\nm = NEM12(to_participant='123')\nm.add_dataframe(nmi='123', interval=5, df=df, uoms={'E1': 'kWh', 'E2': 'kWh'})\noutput = m.output_csv(file_path='output.csv')\n```\n\nIf your DataFrame has a `Quality` and `EventDesc` column, they will also be handled appropriately.\n",
"bugtrack_url": null,
"license": null,
"summary": "nemwriter",
"version": "0.4.6",
"project_urls": {
"Source": "https://github.com/aguinane/nem-writer/"
},
"split_keywords": [
"energy",
"nem12",
"nem13"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "76154b77b96f38517877e53ddde5faddf00c4f9bc741acac4cd74fe3af557e3e",
"md5": "ac5797c3bcfe12be4eaf770c51e7fbed",
"sha256": "778b041aa09a5560f200daa2e6c4cf191387f5437b0f4b5a2c32414048880a76"
},
"downloads": -1,
"filename": "nemwriter-0.4.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ac5797c3bcfe12be4eaf770c51e7fbed",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8730,
"upload_time": "2023-12-14T23:37:31",
"upload_time_iso_8601": "2023-12-14T23:37:31.595416Z",
"url": "https://files.pythonhosted.org/packages/76/15/4b77b96f38517877e53ddde5faddf00c4f9bc741acac4cd74fe3af557e3e/nemwriter-0.4.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9aae586d048681a504cf8e5be4af5f5f04e703f738be3ed27e1a0f3306ae5276",
"md5": "09d1f94c277fb2484ee29ca4e2b92d0c",
"sha256": "c6fa593ad7576fe667b6c2122d1215e2255e888343b7cfae3578f5c255f10400"
},
"downloads": -1,
"filename": "nemwriter-0.4.6.tar.gz",
"has_sig": false,
"md5_digest": "09d1f94c277fb2484ee29ca4e2b92d0c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 53635,
"upload_time": "2023-12-14T23:37:34",
"upload_time_iso_8601": "2023-12-14T23:37:34.034985Z",
"url": "https://files.pythonhosted.org/packages/9a/ae/586d048681a504cf8e5be4af5f5f04e703f738be3ed27e1a0f3306ae5276/nemwriter-0.4.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-14 23:37:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aguinane",
"github_project": "nem-writer",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "nemwriter"
}