File: earray1.py

package info (click to toggle)
pytables 3.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,272 kB
  • sloc: ansic: 82,216; python: 65,569; cpp: 753; sh: 394; makefile: 106
file content (16 lines) | stat: -rw-r--r-- 521 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np

import tables as tb

fileh = tb.open_file("earray1.h5", mode="w")
a = tb.StringAtom(itemsize=8)
# Use ``a`` as the object type for the enlargeable array.
array_c = fileh.create_earray(fileh.root, "array_c", a, (0,), "Chars")
array_c.append(np.array(["a" * 2, "b" * 4], dtype="S8"))
array_c.append(np.array(["a" * 6, "b" * 8, "c" * 10], dtype="S8"))

# Read the string ``EArray`` we have created on disk.
for s in array_c:
    print(f"array_c[{array_c.nrow}] => {s!r}")
# Close the file.
fileh.close()