[AstroPy] Reading/writing tables
Judith Irwin
irwinja at queensu.ca
Tue Dec 8 02:58:30 EST 2020
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 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20201208/b98c1594/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: merged_0.3-7_newerr_src.fits
Type: image/fits
Size: 46080 bytes
Desc: merged_0.3-7_newerr_src.fits
URL: <https://mail.python.org/pipermail/astropy/attachments/20201208/b98c1594/attachment-0001.bin>
More information about the AstroPy
mailing list