Skip to content

Instantly share code, notes, and snippets.

@smoh
Created June 13, 2013 19:11
Show Gist options
  • Save smoh/5776471 to your computer and use it in GitHub Desktop.
Save smoh/5776471 to your computer and use it in GitHub Desktop.
astropy ascii output names issue
In [1]: from astropy.io import ascii
In [2]: from astropy.table import Table
In [3]: data = {'x': [1, 2, 3],
...: 'y': [4, 5.2, 6.1],
...: 'z': [8, 9, 'hello world']}
In [4]: import sys
In [5]: ascii.write(data, sys.stdout, Writer=ascii.FixedWidth)
| y | x | z |
| 4.0 | 1 | 8 |
| 5.2 | 2 | 9 |
| 6.1 | 3 | hello world |
In [7]: ascii.write(data, sys.stdout, names=['x','y','z'], Writer=ascii.FixedWidth)
| x | y | z |
| 1 | 4.0 | 8 |
| 2 | 5.2 | 9 |
| 3 | 6.1 | hello world |
In [8]: t = Table(data)
In [10]: t.write(sys.stdout, format='ascii', Writer=ascii.FixedWidth)
| y | x | z |
| 4.0 | 1 | 8 |
| 5.2 | 2 | 9 |
| 6.1 | 3 | hello world |
In [11]: t.write(sys.stdout, format='ascii', names=['x','y','z'], Writer=ascii.FixedWidth)
| x | y | z |
| 4.0 | 1 | 8 |
| 5.2 | 2 | 9 |
| 6.1 | 3 | hello world |
In [12]: ascii.write(t, sys.stdout, Writer=ascii.FixedWidth)
| y | x | z |
| 4.0 | 1 | 8 |
| 5.2 | 2 | 9 |
| 6.1 | 3 | hello world |
In [13]: ascii.write(t, sys.stdout, names=['x','y','z'], Writer=ascii.FixedWidth)
| x | y | z |
| 4.0 | 1 | 8 |
| 5.2 | 2 | 9 |
| 6.1 | 3 | hello world |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment