%%file /tmp/data.txt
a | b
1 | 2
3 | 4 # this is a comment
# another comment
5 | 6
Overwriting /tmp/data.txt
filename = '/tmp/data.txt'
import numpy as np
np.genfromtxt(filename, names=True, delimiter='|', comments='#')
array([(1.0, 2.0), (3.0, 4.0), (5.0, 6.0)], dtype=[('a', '<f8'), ('b', '<f8')])
from astropy.table import Table
Table.read(filename, format='ascii.csv', delimiter='|', comment='\s*#')
a | b |
---|---|
int64 | str672 |
1 | 2 |
3 | 4 # this is a comment |
5 | 6 |