Created
June 13, 2013 19:11
-
-
Save smoh/5776471 to your computer and use it in GitHub Desktop.
astropy ascii output names issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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