<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 24, 2016 at 6:11 PM, Derek Homeier <span dir="ltr"><<a href="mailto:derek@astro.physik.uni-goettingen.de" target="_blank">derek@astro.physik.uni-goettingen.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 25 Oct 2016, at 12:01 am, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com">nathan12343@gmail.com</a>> wrote:<br>
><br>
> I believe this is issue 2923:<br>
><br>
> <a href="https://github.com/astropy/astropy/issues/2923" rel="noreferrer" target="_blank">https://github.com/astropy/<wbr>astropy/issues/2923</a><br>
><br>
> On Mon, Oct 24, 2016 at 4:45 PM, Benjamin Alan Weaver <<a href="mailto:baweaver@lbl.gov">baweaver@lbl.gov</a>> wrote:<br>
> Hello y'all,<br>
><br>
> We are trying to read "ASCII" tables containing atomic line data<br>
> provided by NIST.  When you request the line wavelength data in<br>
> angstroms, NIST very helpfully labels the columns with the angstrom<br>
> symbol (Å), which is not strictly part of the ASCII character set.<br>
><br>
> We can read these tables with Table.read() *and* the environment<br>
> variable LANG=en_US.utf-8 set.  However, if LANG is not set,<br>
> Table.read() fails to decode these files.<br>
><br>
> As far as I can tell the underlying read() function in astropy.io.ascii<br>
> does not accept keywords related to the file encoding.<br>
><br>
> So two questions:<br>
><br>
> 1. Is the lack of an encoding keyword a bug that should be reported?<br>
><br>
> 2. Is there a workaround that does not rely on LANG being set?<br>
<br>
</span>A workaround that would at least get you away without manipulating the<br>
environment outside Python would be<br>
<br>
import locale<br>
locale.setlocale(locale.LC_<wbr>ALL, str(‘en_US.utf8’))<br></blockquote><div><br></div><div>You can make this a little cleaner using the set_locale context manager in astropy:</div><div><br></div><div><font face="monospace, monospace">from astropy.utils.misc import set_locale</font></div><div><font face="monospace, monospace">with set_locale('en_US.utf8'):</font></div><div><font face="monospace, monospace">    dat = Table.read(...)</font></div><div><br></div><div>As to the original question of whether this should be reported as a bug, it has already been discussed in:</div><div><br></div><div> <a href="https://github.com/astropy/astropy/issues/3826">https://github.com/astropy/astropy/issues/3826</a></div><div><br></div><div>That discussion ended without any really clear consensus except that using Python 3 is a good thing if that is an option.  I have never seriously evaluated how difficult it would be to implement support for unicode inputs for Python 2.  A basic recipe is shown in the stdlib csv package documentation, but I don't know how messy a fully working implementation would get.</div><div><br></div><div>Cheers,</div><div>Tom A</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Cheers,<br>
                                        Derek<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
______________________________<wbr>_________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.scipy.org/<wbr>mailman/listinfo/astropy</a><br>
</div></div></blockquote></div><br></div></div>