[AstroPy] Reading/writing tables

yyang yanbin.yang at obspm.fr
Tue Dec 8 03:08:57 EST 2020


Could it be linked to the your duplicated column named “R” ?  see  a screen shot enclosed.
Cheers
Yanbin


> On 8 Dec 2020, at 08:58, Judith Irwin <irwinja at queensu.ca> wrote:
> 
> Could someone help with this problem? I want to read a fits table and write out a .csv file.  Here is what I'm doing:
> 
> >>> import astropy
> >>> from astropy.table import Table
> >>> from astropy.io <http://astropy.io/> import ascii
> >>> t=Table.read('merged_0.3-7_newerr_src.fits')
> >>> print t
>       RA           DEC            RA_ERR           DEC_ERR            X       ... 797_OFFAXS_ANG WEIGHT_OFFAXS      WANG_ERR         POS_ERR    
>      deg           deg             deg               deg             pix      ...     arcmin         arcmin          arcmin           arcmin    
> ------------- ------------- ----------------- ----------------- ------------- ... -------------- -------------- ---------------- ----------------
> 190.491776756 32.4809974381 7.81833679753e-06  4.8707159408e-06 4071.66367713 ...    2.958585048    2.958585048 0.00652461345853 0.00654797997354
> 190.490783106 32.4956819235 2.04948640032e-05 3.86556461152e-05        4077.8 ...  2.07617011778  2.07617011778 0.00490486335967 0.00556319682508
> (I'm only showing the first rows of the table)
> >>> ascii.write(t, 'Xsources_new.csv', format='csv',overwrite=True)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/home/irwin/.local/lib/python2.7/site-packages/astropy/io/ascii/ui.py", line 733, in write
>     writer.write(table, output)
>   File "/home/irwin/.local/lib/python2.7/site-packages/astropy/io/ascii/fastbasic.py", line 179, in write
>     self._write(table, output, {'fill_values': [(core.masked, '')]})
>   File "/home/irwin/.local/lib/python2.7/site-packages/astropy/io/ascii/fastbasic.py", line 156, in _write
>     writer.write(output, header_output, output_types)
>   File "astropy/io/ascii/cparser.pyx", line 1036, in astropy.io.ascii.cparser.FastWriter.write
> TypeError: unhashable type: 'list'
> >>> ascii.write(t, 'Xsources_new.csv', format='csv',overwrite=True,comment=False)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/home/irwin/.local/lib/python2.7/site-packages/astropy/io/ascii/ui.py", line 733, in write
>     writer.write(table, output)
>   File "/home/irwin/.local/lib/python2.7/site-packages/astropy/io/ascii/fastbasic.py", line 179, in write
>     self._write(table, output, {'fill_values': [(core.masked, '')]})
>   File "/home/irwin/.local/lib/python2.7/site-packages/astropy/io/ascii/fastbasic.py", line 156, in _write
>     writer.write(output, header_output, output_types)
>   File "astropy/io/ascii/cparser.pyx", line 1036, in astropy.io.ascii.cparser.FastWriter.write
> TypeError: unhashable type: 'list'
> 
> 
> I also tried comment=False in the write statement.  I include the input file as an attachment.  Thanks.
> 
> Judith
> 
> <merged_0.3-7_newerr_src.fits>_______________________________________________
> AstroPy mailing list
> AstroPy at python.org <mailto:AstroPy at python.org>
> https://mail.python.org/mailman/listinfo/astropy <https://mail.python.org/mailman/listinfo/astropy>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20201208/1dd34453/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.png
Type: image/png
Size: 29808 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/astropy/attachments/20201208/1dd34453/attachment-0001.png>


More information about the AstroPy mailing list