Slide 32
Slide 32 text
h5py
とPyTables
のデータ互換性
例:PyTables
で作った文字列データを、h5py
で読む
# PyTables
でファイルを作る
with tables.open_file(filepath, 'w') as f:
dataset = f.create_vlarray('/', 'str_data', atom=VLUnicodeAtom())
dataset.append('
シナノゴールド')
# PyTables
で開く
with tables.open_file(filepath, 'r') as f:
node = f.get_node(where='/', name='str_data')
for row in node.iterrows():
print(row) # =>
シナノゴールド
# h5py
で開く
with h5py.File(filepath, mode='r') as f:
dataset = f['str_data']
print(dataset[0]) # => [12471 12490 12494 12468 12540 12523 12489]