astropy/astropy — pull request #2080 by hamogu (2014-08-23 16:25:48+00:00)
Title: io.ascii bug: `fill_values` do not work well with formatted columns

Let's make a simple table with a value I want to replace. (I use `nan`, but `4` or `1.23e+4` probably have the same problem.)
```
In [1]: import astropy.io.ascii as ascii
In [2]: import sys
In [3]: tab = ascii.read(["a b","a nan"])
In [4]: ascii.write(tab,sys.stdout)
a b
a nan
In [5]: ascii.write(tab,sys.stdout, fill_values=[('nan', '---')])
a b
a ---
```
Now, I change the format of the output to some fixed width. Asciitable always strips the whitespace before output, that does not actually change the output on the screen.
```
In [6]: tab['b'].format = '%5.2f'
In [7]: ascii.write(tab,sys.stdout)
a b
a nan
```
However, `'nan'` is no longer replaced.
```
In [8]: ascii.write(tab,sys.stdout, fill_values=[('nan', '---')])
a b
a nan
```
Instead, `' nan'` works:
```
In [9]: ascii.write(tab,sys.stdout, fill_values=[(' nan', '---')])
a b
a ---
```
That's contrary to what the documentation says and to the original intention of the `fill_values`.