title: Read a float binary file into a 2D array in python
body: <p>Now I have a binary file contains float data, each data is 4 bytes, I want to read it into a 2D array, when I use the </p>
  
  <pre><code>B1 = np.fromfile('/home/lijiao/Documents/transform/Data/AHI8_OBI_1000M_NOM_20160812_0040.hdf_B1.dat', dtype=float)
  </code></pre>
  
  <p>It will give me a 1D array of length 60500000, so how to read the data by each 4 bytes? </p>
  
  <p>Edit:
  This is my solution:</p>
  
  <pre><code>filename = '/home/lijiao/Documents/transform/Data/AHI8_OBI_1000M_NOM_20160812_0040.hdf_B1.dat'
  
  with open(filename, 'rb') as f:
  data = np.fromfile(f, dtype=np.float32)
  array = np.reshape(data, [11000, 11000])
  </code></pre>