def write_tables2():
import tables
dtype = np.dtype("S7,f4,f4,f4,f4,i4")
# t0 = time()
# sarray = np.fromiter(((str(i), float(i), float(2*i), None, float(4*i), i)
# for i in xrange(N)), dtype, count=N)
# t1 = time() - t0
# print "Created sarray with %d rows in %.3fs" % (N, t1)
t0 = time()
h5f = tables.openFile("market.h5", "w")
table = h5f.createTable(h5f.root, "market", dtype)
count = 10000
for j in xrange(count, N, count):
sarray = np.fromiter(((str(i), float(i), float(2*i), None, float(4*i), i)
for i in xrange(j)), dtype)
table.append(sarray)
h5f.close()
t1 = time() - t0
print "[PyTables] Stored %d rows in %.3fs" % (N, t1)
评论列表
文章目录