title: Python ASCII codec can't encode character error during write to CSV
body: <p>I'm not entirely sure what I need to do about this error. I assumed that it had to do with needing to add .encode('utf-8'). But I'm not entirely sure if that's what I need to do, nor where I should apply this. </p>
  
  <p><strong>The error is:</strong></p>
  
  <pre><code>line 40, in &lt;module&gt;
  writer.writerows(list_of_rows)
  UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 1
  7: ordinal not in range(128)
  </code></pre>
  
  <p><strong>This is the base of my python script.</strong></p>
  
  <pre><code>import csv
  from BeautifulSoup import BeautifulSoup
  
  url = \
  'https://dummysite'
  
  response = requests.get(url)
  
  html = response.content
  
  soup = BeautifulSoup(html)
  
  table = soup.find('table', {'class': 'table'})
  
  list_of_rows = []
  for row in table.findAll('tr')[1:]:
  list_of_cells = []
  for cell in row.findAll('td'):
      text = cell.text.replace('[','').replace(']','')
      list_of_cells.append(text)
  list_of_rows.append(list_of_cells)
  
  outfile = open("./test.csv", "wb")
  writer = csv.writer(outfile)
  writer.writerow(["Name", "Location"])
  writer.writerows(list_of_rows)
  </code></pre>