You should be able to do this mostly with Astropy. The details are a little vague, but you should be able to read the text file into an Astropy table like: >>> from astropy.table import Table >>> table = Table.read('/path/to/text/file.txt', format='ascii') where the options you end up passing to Table...
From http://docs.astropy.org/en/stable/io/fits/appendix/faq.html#why-is-an-image-containing-integer-data-being-converted-unexpectedly-to-floats If the header for your image contains non-trivial values for the optional BSCALE and/or BZERO keywords (that is, BSCALE != 1 and/or BZERO != 0), then the raw data in the file must be rescaled to its physical values according to the formula: physical_value = BZERO + BSCALE...
I wrote this in the issue opened by the OP, but I'm copying a version of it here too as a possible answer: The issue here is that the CONTINUE convention is strictly limited to extending the value of cards with string values (i.e. it does not apply to cards...
The best answer to this partly depends on how the new table is being created, but as of the latest version of PyFITS (v3.3.0) or Astropy (v0.4.2) the BinTableHDU.from_columns method, which creates a new BINARY table HDU from a set of column definitions accepts an optional header argument which can...