Feb 012010
In a similar vein to reading raw data into Matlab, I created a similar type of function in Python:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | def readraw(filename, shape, intype='int16', byteSwap=False): """ readraw - To read in a raw file and reformat it to the right shape """ # Read in the file if filename.endswith('gz'): fp = gzip.open(filename, 'rb') else: fp = open(filename, 'rb') d = fromfile(file=fp, dtype=intype).reshape(shape) d.byteswap(byteSwap) return d |



Recent Comments