Skip to content Skip to sidebar Skip to footer

How To Merge Two Table With Pyfits?

I am using Python 2.7.10 And pyfits 3.3. Earlier, I have used the following code to merge two tables. However, now I am getting some errors t1 = pyfits.open(table1)[1].columns t2 =

Solution 1:

Is there a reason you cannot use astropy (i.e. astropy.io.fits)?

In that case the idiom would be:

from astropy.table import Table, hstack
t1 = Table.read(table1)
t2 = Table.read(table2)
new = hstack([t1, t2])
new.write(outtable)

In both the read and write calls, you need to provide format='fits' if the table name extension(s) do not imply that it is FITS.


Post a Comment for "How To Merge Two Table With Pyfits?"