Name | daio JSON |
Version |
0.0.6
JSON |
| download |
home_page | None |
Summary | video and data IO tools for Python |
upload_time | 2025-01-31 13:11:06 |
maintainer | None |
docs_url | None |
author | jlab.berlin |
requires_python | >=3.8 |
license | MIT |
keywords |
python
hdf5
data io
video io
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|

[](https://opensource.org/licenses/MIT)

[](https://pypi.org/project/daio/)
[](https://anaconda.org/conda-forge/daio)

# daio
Video and data IO tools for Python.
Links: [API documentation](http://danionella.github.io/daio), [GitHub repository](https://github.com/danionella/daio)
## Installation
- via conda or mamba: `conda install conda-forge::daio`
- if you prefer pip: `pip install daio`
- for development, clone this repository change to the directory containing `pyproject.toml`
- `conda env create -n env_name -f environment.yml`
- `conda activate env_name`
- `pip install -e .`
## Use
### Video IO
Write video:
```python
from daio.video import VideoReader, VideoWriter
writer = VideoWriter('/path/to/video.mp4', fps=25)
for i in range(20):
frame = np.random.randint(0,255,size=(720,1280), dtype='uint8')
writer.write(frame)
writer.close()
```
Read video using speed-optimized array-like indexing or iteration:
```python
reader = VideoReader('/path/to/video.mp4')
frame_7 = reader[7]
first10_frames = reader[:10]
for frame in reader:
process_frame(frame)
reader.close()
```
You can also use with statements to handle file closure:
```python
with VideoWriter('/path/to/video.mp4', fps=25) as writer:
for i in range(20):
frame = np.random.randint(0,255,size=(720,1280), dtype='uint8')
writer.write(frame)
#or
with VideoReader('/path/to/video.mp4') as reader:
frame_7 = reader[7]
```
### HDF5 file IO
Lazily load HDF5 with a dict-like interface (contents are only loaded when accessed):
```python
from daio.h5 import lazyh5
h5 = lazyh5('/path/to/datafile.h5')
b_loaded = h5['b']
e_loaded = h5['c']['e']
h5.keys()
```
Create a new HDF5 file (or add items to existing file by setting argument `readonly=False`):
```python
h5 = lazyh5('test.h5')
h5['a'] = 1
h5['b'] = 'hello'
h5['c'] = {} # create subgroup
h5['c']['e'] = [2,3,4]
```
Load entire HDF5-file to dict, or save dict to HDF5-file:
```python
# save dict to HDF5 file:
some_dict = dict(a = 1, b = np.random.randn(3,4,5), c = dict(g='nested'), d = 'some_string')
lazyh5('/path/to/datafile.h5').from_dict(some_dict)
# load dict from HDF5 file:
loaded = lazyh5('/path/to/datafile.h5').to_dict()
```
In Jupyter, you can interactively explore the file structure:
<img width="598" alt="image" src="https://github.com/user-attachments/assets/878d4af6-ce26-4ec3-9ba5-2701fba1c07e">
-----
<details><summary>Old interface (expand this)</summary>
```python
from daio.h5 import save_to_h5, load_from_h5
# save dict to HDF5 file:
some_dict = dict(a = 1, b = np.random.randn(3,4,5), c = dict(g='nested'), d = 'some_string')
save_to_h5('/path/to/datafile.h5', some_dict)
# load dict from HDF5 file:
dict_loaded = load_from_h5('/path/to/datafile.h5')
```
</details>
Raw data
{
"_id": null,
"home_page": null,
"name": "daio",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "python, HDF5, data IO, video IO",
"author": "jlab.berlin",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/4b/61/2b8500355548fa286a5ba3467dfe05245d58bbb303dc233a0fb2fc89a18e/daio-0.0.6.tar.gz",
"platform": null,
"description": "\n[](https://opensource.org/licenses/MIT)\n\n[](https://pypi.org/project/daio/)\n[](https://anaconda.org/conda-forge/daio)\n\n\n# daio\nVideo and data IO tools for Python.\n\nLinks: [API documentation](http://danionella.github.io/daio), [GitHub repository](https://github.com/danionella/daio)\n\n## Installation\n- via conda or mamba: `conda install conda-forge::daio`\n- if you prefer pip: `pip install daio`\n- for development, clone this repository change to the directory containing `pyproject.toml` \n - `conda env create -n env_name -f environment.yml`\n - `conda activate env_name`\n - `pip install -e .`\n\n## Use \n\n### Video IO\n\nWrite video:\n```python\nfrom daio.video import VideoReader, VideoWriter\nwriter = VideoWriter('/path/to/video.mp4', fps=25)\nfor i in range(20):\n frame = np.random.randint(0,255,size=(720,1280), dtype='uint8')\n writer.write(frame)\nwriter.close()\n```\n\nRead video using speed-optimized array-like indexing or iteration:\n```python\nreader = VideoReader('/path/to/video.mp4')\nframe_7 = reader[7]\nfirst10_frames = reader[:10]\nfor frame in reader:\n process_frame(frame)\nreader.close()\n```\n\nYou can also use with statements to handle file closure:\n```python\nwith VideoWriter('/path/to/video.mp4', fps=25) as writer:\n for i in range(20):\n frame = np.random.randint(0,255,size=(720,1280), dtype='uint8')\n writer.write(frame)\n#or\nwith VideoReader('/path/to/video.mp4') as reader:\n frame_7 = reader[7]\n```\n\n### HDF5 file IO\n\nLazily load HDF5 with a dict-like interface (contents are only loaded when accessed):\n```python\nfrom daio.h5 import lazyh5\nh5 = lazyh5('/path/to/datafile.h5')\nb_loaded = h5['b']\ne_loaded = h5['c']['e']\nh5.keys()\n```\n\nCreate a new HDF5 file (or add items to existing file by setting argument `readonly=False`):\n```python\nh5 = lazyh5('test.h5')\nh5['a'] = 1\nh5['b'] = 'hello'\nh5['c'] = {} # create subgroup\nh5['c']['e'] = [2,3,4]\n```\n\nLoad entire HDF5-file to dict, or save dict to HDF5-file:\n```python\n# save dict to HDF5 file:\nsome_dict = dict(a = 1, b = np.random.randn(3,4,5), c = dict(g='nested'), d = 'some_string')\nlazyh5('/path/to/datafile.h5').from_dict(some_dict)\n# load dict from HDF5 file:\nloaded = lazyh5('/path/to/datafile.h5').to_dict()\n```\n\nIn Jupyter, you can interactively explore the file structure:\n\n<img width=\"598\" alt=\"image\" src=\"https://github.com/user-attachments/assets/878d4af6-ce26-4ec3-9ba5-2701fba1c07e\">\n\n\n-----\n<details><summary>Old interface (expand this)</summary>\n \n```python\nfrom daio.h5 import save_to_h5, load_from_h5\n# save dict to HDF5 file:\nsome_dict = dict(a = 1, b = np.random.randn(3,4,5), c = dict(g='nested'), d = 'some_string')\nsave_to_h5('/path/to/datafile.h5', some_dict)\n# load dict from HDF5 file:\ndict_loaded = load_from_h5('/path/to/datafile.h5')\n```\n\n</details>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "video and data IO tools for Python",
"version": "0.0.6",
"project_urls": {
"Homepage": "https://github.com/danionella/daio"
},
"split_keywords": [
"python",
" hdf5",
" data io",
" video io"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "f62b065701c951e6b011549d366666406db5e6e61eca0022e1ce311ab6f5c7be",
"md5": "de9882e08a8ed131fc95a1565103edae",
"sha256": "0b0611915e1d233eb0c4ed5c75c902e34d6b16ab1b3179e38988654426d19f0a"
},
"downloads": -1,
"filename": "daio-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "de9882e08a8ed131fc95a1565103edae",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9822,
"upload_time": "2025-01-31T13:11:04",
"upload_time_iso_8601": "2025-01-31T13:11:04.713922Z",
"url": "https://files.pythonhosted.org/packages/f6/2b/065701c951e6b011549d366666406db5e6e61eca0022e1ce311ab6f5c7be/daio-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4b612b8500355548fa286a5ba3467dfe05245d58bbb303dc233a0fb2fc89a18e",
"md5": "f271d43a19f1b31bc9d7149431a91ba9",
"sha256": "677980ea470c66e22363553a8b3efb38cb53ae54025a5fed50ad65c1d12ed991"
},
"downloads": -1,
"filename": "daio-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "f271d43a19f1b31bc9d7149431a91ba9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11074,
"upload_time": "2025-01-31T13:11:06",
"upload_time_iso_8601": "2025-01-31T13:11:06.642204Z",
"url": "https://files.pythonhosted.org/packages/4b/61/2b8500355548fa286a5ba3467dfe05245d58bbb303dc233a0fb2fc89a18e/daio-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-31 13:11:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "danionella",
"github_project": "daio",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "daio"
}