0

For example, I have the following table description. In SpectrumL, I would like to store a (spectrogram) I do not know the exact size yet. Similarly, I would like to store some tags (which will be strings) and their size will vary by record. However, when I try to execute the build statement for this, I get the following error:

TypeError: Passing an incorrect value to a table column. Expected a Col (or subclass) instance and got: "StringAtom(itemsize=20, shape=(), dflt='')". Please make use of the Col(), or descendant, constructor to properly initialize columns. 

The statement I am executing is:

h5file = tables.open_file("foo.h5", mode = "w", title = "Datastore")
group = h5file.create_group("/", 'metadata', 'General MetaData')
table =  h5file.create_table(group, 'footer', hdf5Pull.BuildTable, "information")

The table statement class is:

   class BuildTable(IsDescription):
        artist_id = StringCol(100)
        tags = StringAtom(itemsize = 20)
        spectrumL = Float64Atom((5000, 1))
        spectrumR = Float64Atom((5000, 1))
        frequency = Float64Atom((5000, 1))

Might anyone be able to help take a look at this? I'm having a bit of trouble understanding the documentation. Thanks!

mle
  • 289
  • 1
  • 2
  • 12

1 Answers1

0

The error message contains all the information. You have to use Col or subclasses but you are providing Atoms.

The table statement must be something like this:

class BuildTable(IsDescription):
        artist_id = StringCol(100)
        tags = StringCol(itemsize = 20)
        spectrumL = Float64Col(shape=(5000, 1))
        spectrumR = Float64Col(shape=(5000, 1))
        frequency = Float64Col(shape=(5000, 1))

If you want to store multiple values in a single cell you have to rely on multidimensional cells (see here).

Ümit
  • 17,379
  • 7
  • 55
  • 74