title: How to read binary file data into arrays?
body: <p>Attempt to read a binary file in python.  From the <a href="https://docs.python.org/3/library/struct.html" rel="nofollow noreferrer">dataset page</a>:</p>
  
  <blockquote>
    <p>The pixels are stored as unsigned chars (1 byte) and take values from
    0 to 255</p>
  </blockquote>
  
  <p>I have tried the following, which prints <code>(0,)</code>, rather than a 784,000 digit array.</p>
  
  <pre><code># -*- coding: utf8 -*-
  # Processed MNIST dataset (http://cis.jhu.edu/~sachin/digit/digit.html)
  import struct
  
  f = open('data/data0', mode='rb')
  data = []
  
  print struct.unpack('&lt;i', f.read(4))
  </code></pre>
  
  <p>How can I read this binary into either a 784,000 digit array (28 bytes x 28 bytes x 1k samples), or a 28x28x1000 3D array.  I have never worked with binaries before, and am quite confused!</p>