Get data in the table as a (record) array. The start, stop and step parameters can be used to select only a *range of rows* in the table. Their meanings are the same as in the built-in Python slices. If field is supplied only the named column will be selected.
(
self,
start: int | None = None,
stop: int | None = None,
step: int | None = None,
field: str | None = None,
out: np.ndarray | None = None,
)
| 2003 | return result |
| 2004 | |
| 2005 | def read( |
| 2006 | self, |
| 2007 | start: int | None = None, |
| 2008 | stop: int | None = None, |
| 2009 | step: int | None = None, |
| 2010 | field: str | None = None, |
| 2011 | out: np.ndarray | None = None, |
| 2012 | ) -> np.ndarray: |
| 2013 | """Get data in the table as a (record) array. |
| 2014 | |
| 2015 | The start, stop and step parameters can be used to select only |
| 2016 | a *range of rows* in the table. Their meanings are the same as |
| 2017 | in the built-in Python slices. |
| 2018 | |
| 2019 | If field is supplied only the named column will be selected. |
| 2020 | If the column is not nested, an *array* of the current flavor |
| 2021 | will be returned; if it is, a *structured array* will be used |
| 2022 | instead. If no field is specified, all the columns will be |
| 2023 | returned in a structured array of the current flavor. |
| 2024 | |
| 2025 | Columns under a nested column can be specified in the field |
| 2026 | parameter by using a slash character (/) as a separator (e.g. |
| 2027 | 'position/x'). |
| 2028 | |
| 2029 | The out parameter may be used to specify a NumPy array to |
| 2030 | receive the output data. Note that the array must have the |
| 2031 | same size as the data selected with the other parameters. |
| 2032 | Note that the array's datatype is not checked and no type |
| 2033 | casting is performed, so if it does not match the datatype on |
| 2034 | disk, the output will not be correct. |
| 2035 | |
| 2036 | When specifying a single nested column with the field parameter, |
| 2037 | and supplying an output buffer with the out parameter, the |
| 2038 | output buffer must contain all columns in the table. |
| 2039 | The data in all columns will be read into the output buffer. |
| 2040 | However, only the specified nested column will be returned from |
| 2041 | the method call. |
| 2042 | |
| 2043 | When data is read from disk in NumPy format, the output will be |
| 2044 | in the current system's byteorder, regardless of how it is |
| 2045 | stored on disk. If the out parameter is specified, the output |
| 2046 | array also must be in the current system's byteorder. |
| 2047 | |
| 2048 | .. versionchanged:: 3.0 |
| 2049 | Added the *out* parameter. Also the start, stop and step |
| 2050 | parameters now behave like in slice. |
| 2051 | |
| 2052 | Examples |
| 2053 | -------- |
| 2054 | Reading the entire table:: |
| 2055 | |
| 2056 | t.read() |
| 2057 | |
| 2058 | Reading record n. 6:: |
| 2059 | |
| 2060 | t.read(6, 7) |
| 2061 | |
| 2062 | Reading from record n. 6 to the end of the table:: |