<p>This is what I do when I have to read arbitrary in an heterogeneous binary file.<br>
Numpy allows to interpret a bit pattern in arbitray way by changing the <a href="http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html" rel="nofollow">dtype</a> of the array. 
The Matlab code in the question reads a <code>char</code> and two <code>uint</code>.</p>

<p>Read this <a href="http://arxiv.org/pdf/1102.1523.pdf" rel="nofollow">paper</a> (easy reading on user level, not for scientists) on what one can achieve with changing the dtype, stride, dimensionality of an array.</p>

<pre><code>import numpy as np

data = np.arange(10, dtype=np.int)
data.tofile('f')

x = np.fromfile('f', dtype='u1')
print x.size
# 40

second = x[8]
print 'second', second
# second 2

total_cycles = x[8:12]
print 'total_cycles', total_cycles
total_cycles.dtype = np.dtype('u4')
print 'total_cycles', total_cycles
# total_cycles [2 0 0 0]       !endianness
# total_cycles [2]

start_cycle = x[12:16]
start_cycle.dtype = np.dtype('u4')
print 'start_cycle', start_cycle
# start_cycle [3]

x.dtype = np.dtype('u4')
print 'x', x
# x [0 1 2 3 4 5 6 7 8 9]

x[3] = 423 
print 'start_cycle', start_cycle
# start_cycle [423]
</code></pre>
How to read part of binary file with numpy?
<p>I'm converting a matlab script to numpy, but have some problems with reading data from a binary file. Is there an equivelent to <code>fseek</code> when using <code>fromfile</code> to skip the beginning of the file? This is the type of extractions I need to do:</p>

<pre><code>fid = fopen(fname);
fseek(fid, 8, 'bof');
second = fread(fid, 1, 'schar');
fseek(fid, 100, 'bof');
total_cycles = fread(fid, 1, 'uint32', 0, 'l');
start_cycle = fread(fid, 1, 'uint32', 0, 'l');
</code></pre>

<p>Thanks!</p>