Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliaio/hdf5.jl
Save and load data in the HDF5 file format from Julia
https://github.com/juliaio/hdf5.jl
data-storage hacktoberfest hdf5 hdf5-binaries hdf5-files hdf5-library jld julia julia-language mat
Last synced: 5 days ago
JSON representation
Save and load data in the HDF5 file format from Julia
- Host: GitHub
- URL: https://github.com/juliaio/hdf5.jl
- Owner: JuliaIO
- License: mit
- Created: 2012-10-01T01:08:41.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T22:31:07.000Z (4 months ago)
- Last Synced: 2024-10-29T15:47:48.032Z (4 months ago)
- Topics: data-storage, hacktoberfest, hdf5, hdf5-binaries, hdf5-files, hdf5-library, jld, julia, julia-language, mat
- Language: Julia
- Homepage: https://juliaio.github.io/HDF5.jl
- Size: 9.88 MB
- Stars: 390
- Watchers: 17
- Forks: 143
- Open Issues: 106
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE.txt
Awesome Lists containing this project
README
_HDF5 interface for the Julia language_
-[HDF5](https://www.hdfgroup.org/solutions/hdf5/) is a file format and library for storing and
accessing data, commonly used for scientific data. HDF5 files can be created and read by numerous
[programming languages](https://en.wikipedia.org/wiki/Hierarchical_Data_Format#Interfaces). This
package provides an interface to the HDF5 library for the Julia language.[](https://JuliaIO.github.io/HDF5.jl/stable)
[](https://github.com/JuliaIO/HDF5.jl/actions)
[](https://codecov.io/gh/JuliaIO/HDF5.jl)### Changelog
Please see [HISTORY.md](HISTORY.md) and the [release notes](https://github.com/JuliaIO/HDF5.jl/releases). Most changes have deprecation warnings and may not be listed in the [HISTORY.md](HISTORY.md) file.
### Installation
```julia
julia>]
pkg> add HDF5
```
For custom build instructions please refer to the [documentation](https://juliaio.github.io/HDF5.jl/stable/#Using-custom-or-system-provided-HDF5-binaries).### Quickstart
```julia
using HDF5
```To read and write a variable to a file, one approach is to use the filename:
```julia
A = collect(reshape(1:120, 15, 8))
h5write("/tmp/test2.h5", "mygroup2/A", A)
data = h5read("/tmp/test2.h5", "mygroup2/A", (2:3:15, 3:5))
```
where the last line reads back just `A[2:3:15, 3:5]` from the dataset.More fine-grained control can be obtained using functional syntax:
```julia
h5open("mydata.h5", "w") do file
write(file, "A", A) # alternatively, say "@write file A"
endc = h5open("mydata.h5", "r") do file
read(file, "A")
end
```
This allows you to add variables as they are generated to an open HDF5 file.
You don't have to use the `do` syntax (`file = h5open("mydata.h5", "w")` works
just fine), but an advantage is that it will automatically close the file (`close(file)`)
for you, even in cases of error.Julia's high-level wrapper, providing a dictionary-like interface, may
also be of interest:```julia
using HDF5h5open("test.h5", "w") do file
g = create_group(file, "mygroup") # create a group
g["dset1"] = 3.2 # create a scalar dataset inside the group
attributes(g)["Description"] = "This group contains only a single dataset" # an attribute
end
```Convenience functions for attributes attached to datasets are also provided:
```julia
A = Vector{Int}(1:10)
h5write("bar.h5", "foo", A)
h5writeattr("bar.h5", "foo", Dict("c"=>"value for metadata parameter c","d"=>"metadata d"))
h5readattr("bar.h5", "foo")
```