title: Python Inserting Unwanted Characters
body: <p>I'm trying to use Python to generate a collection of HTML tables with values pulled from a CSV. The script is working fine, however it's adding in odd "¬†" characters wherever a value is pulled in.</p>
  
  <p>This is the code I used to grab the CSV data:</p>
  
  <pre><code>import csv
  import fileinput
  import re
  
  out=open("audiencestats.csv","rU")
  data=csv.reader(out)
  values =[row for row in data]
  metrics = values.pop(0) 
  out.close()
  </code></pre>
  
  <p>This creates a function to make the html tables:</p>
  
  <pre><code>def maketable(leftmetric, rightmetric, leftvalue, rightvalue):
    template = '''
    &lt;table width="99%%" border="1"&gt; 
     &lt;tbody&gt;
      &lt;tr&gt;
      &lt;td align="center" valign="middle"&gt;
      &lt;h3&gt;%s&lt;/h3&gt;
      &lt;/td&gt;
      &lt;td align="center" valign="middle"&gt;
      &lt;h3&gt;%s&lt;/h3&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td align="center" valign="middle"&gt; %s&lt;/td&gt;
      &lt;td align="center" valign="middle"&gt; %s&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    '''
    file.write(template % (leftmetric, rightmetric, leftvalue, rightvalue))
  </code></pre>
  
  <p>Then this writes the tables to text files:</p>
  
  <pre><code>for i in values:
    filename = "%s.txt" % i[0]
    file = open(filename , 'w')
    file.write(header)
    maketable(metrics[1],metrics[2],i[1],i[2])
    maketable(metrics[3],metrics[4],i[3],i[4])
    maketable(metrics[5],metrics[6],i[5],i[6])
    maketable(metrics[7],metrics[8],i[7],i[8])
    maketable(metrics[9],metrics[10],i[9],i[10])
    maketable(metrics[11],metrics[12],i[11],i[12])
    file.write(header2)
    print makesocial(i[13],i[14],i[15])
    file.close()
  </code></pre>
  
  <p>I tried adding in the below re.sub to the for loop, but the crosses remain.</p>
  
  <pre><code>for line in fileinput.input(inplace=1):
      line = re.sub('¬†','', line.rstrip())
      print(line)
  </code></pre>
  
  <p>Am I missing something? Has my computer turned religious?</p>
  
  <p>Example of the output copied below as well:</p>
  
  <pre><code>&lt;h1&gt;Audience&lt;/h1&gt;
    &lt;table width="99%" border="1"&gt; 
     &lt;tbody&gt;
      &lt;tr&gt;
      &lt;td align="center" valign="middle"&gt;
      &lt;h3&gt;UVs (000)&lt;/h3&gt;
      &lt;/td&gt;
      &lt;td align="center" valign="middle"&gt;
      &lt;h3&gt;PVs (000)&lt;/h3&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td align="center" valign="middle"&gt;¬†580.705&lt;/td&gt;
      &lt;td align="center" valign="middle"&gt;¬†1003&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  </code></pre>