MCPcopy Create free account
hub / github.com/PyTables/PyTables / create_file

Function create_file

bench/stress-test3.py:26–74  ·  view source on GitHub ↗
(
    filename, ngroups, ntables, nrows, complevel, complib, recsize
)

Source from the content-addressed store, hash-verified

24
25
26def create_file(
27 filename, ngroups, ntables, nrows, complevel, complib, recsize
28):
29
30 # First, create the groups
31
32 # Open a file in "w"rite mode
33 fileh = tb.open_file(filename, mode="w", title="PyTables Stress Test")
34
35 for k in range(ngroups):
36 # Create the group
37 group = fileh.create_group("/", "group%04d" % k, "Group %d" % k)
38
39 fileh.close()
40
41 # Now, create the tables
42 rowswritten = 0
43 rowsize = 0
44 for k in range(ngroups):
45 fileh = tb.open_file(filename, mode="a", root_uep="group%04d" % k)
46 # Get the group
47 group = fileh.root
48 for j in range(ntables):
49 # Create a table
50 table = fileh.create_table(
51 group,
52 "table%04d" % j,
53 Test,
54 "Table%04d" % j,
55 tb.Filters(complevel, complib),
56 nrows,
57 )
58 rowsize = table.rowsize
59 # Get the row object associated with the new table
60 row = table.row
61 # Fill the table
62 for i in range(nrows):
63 row["ngroup"] = k
64 row["ntable"] = j
65 row["nrow"] = i
66 row.append()
67
68 rowswritten += nrows
69 table.flush()
70
71 # Close the file
72 fileh.close()
73
74 return (rowswritten, rowsize)
75
76
77def read_file(filename, ngroups, recsize, verbose):

Callers 1

stress-test3.pyFile · 0.70

Calls 5

create_groupMethod · 0.80
closeMethod · 0.45
create_tableMethod · 0.45
appendMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected