class Particle(tb.IsDescription):
name = tb.StringCol(16, pos=1) # 16-character String
lati = tb.IntCol(pos=2) # integer
longi = tb.IntCol(pos=3) # integer
pressure = tb.Float32Col(pos=4) # float (single-precision)
temperature = tb.FloatCol(pos=5) # double (double-precision)
import tables as tb, numpy as np
class Particle(tb.IsDescription):
name = tb.StringCol(16) # 16-character String
h5f = tb.open_file("particle_t1.h5", mode="w", title="Test file")
group1 = h5f.create_group("/", 'detector1', 'Detector1 information')
table1 = h5f.create_table(group1, 'readout1', Particle, "Readout example")
particle = table1.row
for i in range(3):
particle['name'] = 'Particle: %6d' % (i)
particle.append()
table1.flush()
for x in table1.iterrows() :
print (x['name'])
h5f.close()
import tables as tb
class Particle(tb.IsDescription):
name = tb.StringCol(16, pos=1) # 16-character String
h5f = tb.open_file('append_t1.h5', mode='w')
group1 = h5f.create_group("/", 'detector1', 'Detector1 information')
table1 = h5f.create_table(group1, 'readout1', Particle, "A table")
# Append several rows in only one call
table1.append([("Particle: 10"),
("Particle: 11"),
("Particle: 12")])
for x in table1.iterrows():
print (x['name'])
h5f.close()
b'Particle: 10'
b'Particle: 11'
b'Particle: 12'
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-user...@googlegroups.com.
To post to this group, send email to pytable...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.