Python:Got \xa0 instead of space in CSV and cannot remove or convert
<p>I have a problem related to the encoding problem in python (IPython notebook ). As these kind of problems is very common and simple, but I still cannot really fix it.</p>

<p>I have a <a href="http://www.montefiore.ulg.ac.be/~glouppe/2012-2013/challenge/train.csv" rel="noreferrer">CSV</a> file here, as you can see we got many '\xa0' and other '\n' characters in this file.</p>

<p>I used </p>

<pre><code>with io.open(train_fname) as f:
for line in f:
    line = line.encode("ascii", "replace")
</code></pre>

<p>But it is not working, I always get the following output.</p>

<blockquote>
  <p>Imagine being able say, you know what, no sanctions, no forever hearings on IEAA regulations, no more hiding\xa0under\xa0the pretense of friendly nuclear energy. \xa0You have 2 days to; \xa0i.e. \xa0let in the inspectors, quit killing the civilians.</p>
</blockquote>

<p>I tried other methods like </p>

<p><code>line.replace(u"\xa0", " ")</code>
It is not working either, I also tried all kinds of encoding to open this CSV file in my text edit, sublime text.
I tried windows-1252, utf-8 and all other encodings, but I always get \xa0 is my text edit when viewing this CSV file.</p>

<p>Does this mean the </p>

<blockquote>
  <p>\xa0</p>
</blockquote>

<p>is already written in this CSV file as input text? It is not a problem of python encoding? If it is this case, why cannot I use replace method to simply replace this string? The \xa0 indicates the file is encoding in which encode? This means this file is written in utf-8 but I tried to open it in ascii or other case?</p>

<p>I searched many questions but they don't seem provide much help. Please ask me if my question is not very clear.
Thank you very much!</p>

<p>`</p>