(filename, field, rng, verbose)
| 244 | |
| 245 | |
| 246 | def read_field(filename, field, rng, verbose): |
| 247 | fileh = tb.open_file(filename, mode="r") |
| 248 | rowsread = 0 |
| 249 | if rng is None: |
| 250 | rng = [0, -1, 1] |
| 251 | if field == "all": |
| 252 | field = None |
| 253 | for groupobj in fileh.walk_groups(fileh.root): |
| 254 | for table in fileh.list_nodes(groupobj, "Table"): |
| 255 | rowsize = table.rowsize |
| 256 | # table.nrowsinbuf = 3 # For testing purposes |
| 257 | if verbose: |
| 258 | print("Max rows in buf:", table.nrowsinbuf) |
| 259 | print("Rows in", table._v_pathname, ":", table.nrows) |
| 260 | print("Buffersize:", table.rowsize * table.nrowsinbuf) |
| 261 | print("MaxTuples:", table.nrowsinbuf) |
| 262 | print( |
| 263 | "(field, start, stop, step) ==>", |
| 264 | (field, rng[0], rng[1], rng[2]), |
| 265 | ) |
| 266 | |
| 267 | e = table.read(rng[0], rng[1], rng[2], field) |
| 268 | |
| 269 | rowsread += table.nrows |
| 270 | if verbose: |
| 271 | print("Selected rows ==> ", e) |
| 272 | print("Total selected rows ==> ", len(e)) |
| 273 | |
| 274 | # Close the file (eventually destroy the extended type) |
| 275 | fileh.close() |
| 276 | return (rowsread, rowsize) |
| 277 | |
| 278 | |
| 279 | if __name__ == "__main__": |
no test coverage detected