These are chat archives for astropy/ci-helpers

20th
Jul 2016
Thomas Robitaille
@astrofrog
Jul 20 2016 00:26
@Danni3l - sorry for the delay, in future ask your question in the astropy channel (this is ci-helpers) since it is more active :) But since you are here, I can help you. Basically, if you have FITS files, the easiest way to append rows is to read in the FITS file via the Table interface and use add_row
so e.g.:
t = Table.read('myfile.fits')
t.add_row(...)
t.write('mynewfile.fits')
Daniel Mendes
@Danni3l
Jul 20 2016 10:14
Thank you for your help !
Daniel Mendes
@Danni3l
Jul 20 2016 10:28

When i try to open the fits file with t = Table.read('myfile.fits') i got an error.*
My first idea was to open it like:

inp = fits.open(sample) 
tbl = inp[1].data
tbl = Table(ttbl)

but doing this i also get an error when i use add_row()

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
C:\Users\daniel\Desktop\specphotoClassif5QGS.py in <module>()
    148     qTbl = Table(qtbl)
    149
--> 150     mtbl.add_row(gTbl)
    151     mtbl.add_row(qTbl)
    152     '''

C:\Users\daniel\Downloads\WinPython-64bit-3.4.4.2\python-3.4.4.amd64\lib\site-packages\astropy\table\table.py in add_row(self, vals, mask)
   2030              3   6   9
   2031         """
-> 2032         self.insert_row(len(self), vals, mask)
   2033
   2034     def insert_row(self, index, vals=None, mask=None):

C:\Users\daniel\Downloads\WinPython-64bit-3.4.4.2\python-3.4.4.amd64\lib\site-packages\astropy\table\table.py in insert_row(self, index, vals, mask)
   2119
   2120             if len(self.columns) != len(vals):
-> 2121                 raise ValueError('Mismatch between number of vals and columns')
   2122
   2123             if mask is not None:

ValueError: Mismatch between number of vals and columns