client side tool for openenergy platform
Project description
OEP Client
This tool eases data sharing with the Open Energy Platform (OEP). Common tasks on the OEP are:
- creating a table
- uploading data
- updating a table's metadata
- downloading data
- retrieving a table's metadata
- deleting a table (that you created)
You can also always just use the API directly if your tasks are more complex.
Notes for Windows Users
All the example commands below use python3, because we need python 3. Under
Windows, it's most likely to be python.exe or just python.
Installation
Install package oep-client from python package index with pip:
python3 -m pip install --upgrade oep-client
Authentification
You need to be registered on the OEP platform and have a valid API token. You can find your token in your user profile on the OEP under Your Security Information.
Test
There is a short test script that creates a table on the platform, uploads data and metadata, downloads them again and finally deletes the table.
You can run it either directly from the command prompt using
oep-client -t OEP_API_TOKEN test
Notes on Data and Metadata
Supported filetypes that the client can work with are are: xslx, csv, json. Your metadata must be a json file that complies with the metadata specification of the OEP.
Notes on Usage
All tasks can be executed either directly as a comand line script (CLI)
oep-client that comes with this package, or in a python environment.
The CLI is very handy for standardized tasks as it requires just one command line, but is somewhat limited when for instance your input data is not in a very specific format. To see avaiblabe command line options, use
oep-client --help
In a python environment, you have more flexibility to prepare / clean your data before uploading it.
Using the CLI
Creating a table
Requires a valid metadata file.
You need to specify names and data types of your columns in the metadata, which also must be valid postgres data types.
metadata.json
{
"resources": [
{
"schema": {
"fields": [
{
"name": "id",
"type": "bigserial"
},
{
"name": "field_1",
"type": "varchar(32)",
"description": "column description",
"unit": "unit name"
}
]
}
}
]
}
oep-client -t OEP_API_TOKEN create TABLE_NAME metadata.json
Uploading data
oep-client -t OEP_API_TOKEN insert TABLE_NAME FILENAME
if FILENAME is a
xlsx, you have to also specify--sheet SHEETNAMEcsv, you may also specify--delimiter DELIMITERand or--encoding ENCODING
Updating a table's metadata
This of course requires a valid metadata file.
oep-client -t OEP_API_TOKEN metadata set TABLE_NAME metadata.json
Downloading data
Note: you do not need an API_TOKEN to downlad data
oep-client -t OEP_API_TOKEN select TABLE_NAME FILENAME
if FILENAME is a
xlsx, you have to also specify--sheet SHEETNAMEcsv, you may also specify--delimiter DELIMITERand or--encoding ENCODING
Retrieving a table's metadata
Note: you do not need an API_TOKEN to downlad metadata.
oep-client -t OEP_API_TOKEN metadata get TABLE_NAME FILENAME
Deleting a table (that you created)
oep-client -t OEP_API_TOKEN drop TABLE_NAME
Using the Package in Python
All examples assume that you import the package and create a client instance first:
from oep_client import OepClient
cl = OepClient(token='API_TOKEN', ...)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oep_client-0.19.0.tar.gz.
File metadata
- Download URL: oep_client-0.19.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04459cf03058a7014ded6a7b3aac02b31143b5d543cc97ba2b65e7a12f73c947
|
|
| MD5 |
841d10ac3211b1c32032c02255a5c813
|
|
| BLAKE2b-256 |
10ab57afa62f12c29fb402130637c4801b04763ba1dcf906e6bb5505863e8d72
|
File details
Details for the file oep_client-0.19.0-py3-none-any.whl.
File metadata
- Download URL: oep_client-0.19.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a3abe83da2d9fc92bc4d90ccc42d264d8f9cf0249da7b643b15cfc6263b0e24
|
|
| MD5 |
42b8f6f51dc0a0158e1067123f60976b
|
|
| BLAKE2b-256 |
4d564940a640874f9f6634363930a29d16844d2447032f65558874fff5e5a5ec
|