create_table
- ketos.data_handling.database_interface.create_table(h5file, path, name, description, data_name='data', chunkshape=None, verbose=False)[source]
Create a new table.
If the table already exists, open it.
- Args:
- h5file: tables.file.File object
HDF5 file handler.
- path: str
The group where the table will be located. Ex: ‘/features/spectrograms’
- name: str
The name of the table.
- table_description: class (tables.IsDescription)
The class describing the table structure.
- data_name: str or list(str)
Name(s) of the table column(s) used to store the data array(s).
- chunkshape: tuple
The chunk shape to be used for compression
- Returns:
- table: table.Table object
The created/open table.
- Examples:
>>> import tables >>> from ketos.data_handling.database_interface import open_file, table_description, create_table >>> # Open a connection to the database >>> h5file = open_file("ketos/tests/assets/tmp/database1.h5", 'w') >>> # Create table descriptions for weakly labeled spectrograms with shape (32,64) >>> descr = table_description((32,64), include_label=False) >>> # Create 'table_data' within 'group1' >>> my_table = create_table(h5file, "/group1/", "table_data", descr) >>> # Show the table description, with the field names (columns) >>> # and information about types and shapes >>> my_table /group1/table_data (Table(0,)fletcher32, shuffle, zlib(1)) '' description := { "data": Float32Col(shape=(32, 64), dflt=0.0, pos=0), "filename": StringCol(itemsize=100, shape=(), dflt=b'', pos=1), "id": UInt32Col(shape=(), dflt=0, pos=2), "offset": Float64Col(shape=(), dflt=0.0, pos=3)} byteorder := 'little' chunkshape := (15,) >>> # Close the HDF5 database file >>> h5file.close()