MCAP libraries for Python
Project description
MCAP Python Library
This library provides classes for reading and writing the MCAP file format.
Reader Example
from mcap.mcap0.stream_reader import StreamReader
stream = open("example.mcap", "rb")
reader = StreamReader(stream)
for record in reader.records:
print(record)
Writer Example
from time import time_ns
import json
from mcap.mcap0.writer import Writer
stream = open("example.mcap", "wb")
writer = Writer(stream)
# The library argument help identify what tool wrote the file.
writer.start(profile="x-custom", library="my-writer-v1")
schema_id = writer.register_schema(
name="sample",
encoding="jsonschema",
data=json.dumps({
"type": "object",
"properties": {
"sample": {
"type": "string",
}
}
}).encode()
)
channel_id = writer.register_channel(
schema_id=schema_id,
topic="sample_topic",
message_encoding="json",
)
writer.add_message(
channel_id=channel_id,
log_time=time_ns(),
data=json.dumps({"sample": "test"}).encode('utf-8'),
publish_time=time_ns(),
)
writer.finish()
stream.close()
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
mcap-0.0.6.tar.gz
(11.8 kB
view details)
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
mcap-0.0.6-py3-none-any.whl
(14.6 kB
view details)
File details
Details for the file mcap-0.0.6.tar.gz.
File metadata
- Download URL: mcap-0.0.6.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28b8ed85faab1bea22fbfcf6e192c30895728c4f710c3a7396c9e370259cfb72
|
|
| MD5 |
30db17745940921a5f8d6c037cb0d90d
|
|
| BLAKE2b-256 |
615648205f041f4055fe7b5a3efea817a2bdac1f51803fc90fc04c304392464f
|
File details
Details for the file mcap-0.0.6-py3-none-any.whl.
File metadata
- Download URL: mcap-0.0.6-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b192bb7091777ebfbe991c7faecaeedecf7407f2cd5d2eedfa8abb66481230bd
|
|
| MD5 |
97fe5b36eba1d74ff0927a941c1be104
|
|
| BLAKE2b-256 |
cbe967e0fd6cdf8294bad602e4e9ba6ee6c36de4a9c45996b6e0d0408df32beb
|