Attributes
- endian
endian = property(get_endian, set_endian, None, 'get/set endian code')
Method summary
- __del__(self)
- __init__(self, file_name, permission = 'rb', endian = 'dtype', order = 'C')
- close(self)
- get_endian(self)
- parse_endian(self, endian_code)
- read_array(self, dt, shape = -Const(1), endian = None, order = None)
- read_raw(self, size = -Const(1))
- remaining_bytes(self)
- rewind(self, howmany = None)
- seek(self, *args)
- set_endian(self, endian_code)
- tell(self)
- write_array(self, data, endian = None, order = None)
- write_raw(self, str)
Methods
- __del__(self)
- __init__(self, file_name, permission = 'rb', endian = 'dtype', order = 'C')
- close(self)
- get_endian(self)
- parse_endian(self, endian_code)
Returns valid endian code from wider input options
- read_array(self, dt, shape = -Const(1), endian = None, order = None)
Read data from file and return it in a numpy array. Inputs ------ dt - dtype of array to be read shape - shape of output array, or number of elements (-1 as number of elements or element in shape means unknown dimension as in reshape; size of array calculated from remaining bytes in file) endian - endianness of data in file (can be None, 'dtype', '<', '>') (if None, get from self.endian) order - order of array in file (C, F) (if None get from self.order) Outputs arr - array from file with given dtype (dt) - read_raw(self, size = -Const(1))
Read raw bytes from file as string.
- remaining_bytes(self)
- rewind(self, howmany = None)
Rewind a file to its beginning or by a specified amount.
- seek(self, *args)
- set_endian(self, endian_code)
- tell(self)
- write_array(self, data, endian = None, order = None)
Write to open file object the flattened numpy array data Inputs data - numpy array or object convertable to array endian - endianness of written data (can be None, 'dtype', '<', '>') (if None, get from self.endian) order - order of array to write (C, F) (if None from self.order) - write_raw(self, str)
Write string to file as raw bytes.
