In this repository we have two modules: mosaik_csv and mosaik_csv_writer.
Installation
$ pip install mosaik-csv
If installation of psutil fails, installing python developer edition and gcc should help:
$ sudo apt-get install gcc python3-dev
mosaik_csv
This simulator reads CSV data and sends it to mosaik.
The following code shows an example how to use the mosaik_csv simulator. The date_format, delimiter parameter and type are optional. If they are not defined, the standard value is ‘YYYY-MM-DD HH:mm:ss’ for the date_format, ‘,’ for delimiter and time-based for type. The first line of the CSV file refers to the model name. If no model name is defined, ‘Data’ is set as the default:
sim_config = {
'CSV': {
'python': 'mosaik_csv:CSV',
}
}
world = mosaik.World(sim_config)
csv_sim = world.start('CSV', sim_start='01.01.2016 00:00',
datafile='data.csv',
date_format='DD.MM.YYYY HH:mm',
delimiter=',',type=time-based)
csv = csv_sim.Data.create(20)
mosaik_csv_writer
This simulator writes simulation results to a CSV file.
The following code shows an example how to use the mosaik_csv_writer simulator. The date_format, delimiter parameter and print_results are optional. If they are not defined, the standard value is ‘YYYY-MM-DD HH:mm:ss’ for the date_format, ‘,’ for delimiter and False for print_results.
While creating the instance of the mosaik_csv_writer (csv_writer = csv_sim_writer.Monitor(buff_size = 30 * 60)) the user can define a buff_size depending on the simulation time (default buff_size = 500). This buff_size tells the simulator to write the data into a CSV file after every defined buffer duration. This feature speeds up the writing process of the simulator. In the given example the simulator will write the accumulated data into a CSV file after every 30 minutes simulation time (30 * 60 simulation steps):
sim_config = {
'CSV_writer': {
'python': 'mosaik_csv_writer:CSVWriter',
}
}
world = mosaik.World(sim_config)
csv_sim_writer = world.start('CSV_writer', start_date = '01.01.2016 00:00',
date_format='%Y-%m-%d %H:%M:%S',
output_file='results.csv')
csv_writer = csv_sim_writer.CSVWriter(buff_size = 30 * 60) # write data after every 30 mins
Tests
You can run the tests with:
$ git clone https://gitlab.com/mosaik/mosaik-csv.git $ cd mosaik-csv $ pip install -r requirements.txt $ pip install -e . $ pytest tests
Changelog
2.0.1 - 2024-05-17
[BUGFIX] Convert numpy data types to python scalars.
2.0.0 - 2023-11-21
[CHANGE] Use pandas for CSV reader.
[NEW] Add CSV writer.
1.2.0 - 2021-05-21
[CHANGE] Updated to mosaik-api 3.0.
1.1.0 - 2021-03-11
[FEATURE] Allow to define the delimiter.
[FEATURE] Allow to define the date format.
1.0.4 - 2021-03-04
[CHANGE] Adjustment to new arrow API.
1.0.3 – 2019-10-10
[CHANGE] Added closing of input file.
[CHANGE] Adjustment to new arrow API.
1.0.2 – 2014-09-22
[CHANGE] Updated to mosaik-api 2.0.
1.0.1 – 2014-06-23
[CHANGE] Updated to mosaik-api 2.0a3.
1.0 – 2014-03-26
Initial release
Metadata
Release files for mosaik-csv 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mosaik-csv-2.0.1.tar.gz | 15.2 kB | Without provenance | Details for mosaik-csv-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mosaik_csv-2.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for mosaik_csv-2.0.1-py2.py3-none-any.whl |
Total release size: 30.4 kB
Release files / mosaik-csv-2.0.1.tar.gz
| Download URL | mosaik-csv-2.0.1.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
449419148cf2906b5db8e1c27ce8f0a3e6e081f9ead4f24a34b8b7f1eec2fa1f
|
|
BLAKE2b-256 checksum How to use checksums |
68fb9c9fe27526e72f571445c3751413a428fed029a9b4199c0d5eed9c002c3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Release files / mosaik_csv-2.0.1-py2.py3-none-any.whl
| Download URL | mosaik_csv-2.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
1be1cd4c7f8f7f5ce8d6b5f6693ee0030541d0deb78c221a7b8376e031059bc4
|
|
BLAKE2b-256 checksum How to use checksums |
f3a3a3164a867f1f5aa73b9e938674e3f0351c71b29d67bcb6ed969035bb8a86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Security for mosaik-csv 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.