title: Parsing Binary files that contains BCD (Binary Coded Decimal) values using Python Numpy
body: <p>I have a binary file that has some fields encoded as BCD (Binary Coded Decimal). Example as below.</p>
  
  <p>14 75 26 58 87 7F (Raw bytes in hex format).</p>
  
  <p>I am using (np.void, 6) to read and convert from binary file and below is the output I am getting. </p>
  
  <p>b'\x14\x75\x26\x58\x87\x7F'</p>
  
  <p>But I would like to get the output as '14752658877', without the fill character 'F' using numpy. </p>
  
  <p>Below is the code:
  with open (filename, "rb") as f:</p>
  
  <pre><code>    while True:
  
          chunk = f.read(chunksize)
  
          if (chunk):
  
              dt = np.dtype([('a','b'), ('b', '&gt;i4'), ('c', 'S15'),('d', np.str, 7),
                                     ('e', 'S7'), ('f', np.void, 6)])
  
              x = np.frombuffer (chunk, dtype=dt)
              print (x)
  
          else:
              break
  </code></pre>
  
  <p>Also, the input file contains many fixed length binary records. What is the efficient way to convert and store it as ascii file using numpy. </p>