I'm parsing a html table using BS4 in python. Everything works fine and I'm able do identify all the elements that i need and print they. But the program stops working then I try to write the results into a text file. I get this error:
"UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 13: ordinal not in range(128)"
I have tried to use .encode('utf-8') in the writing command but I get something like this written : 31.61 
Here's what I'm running. I used code structure to parse another table and it worked. I appreciate if anyone can point me in the right direction.
from threading import Thread
import urllib2
import re
from bs4 import BeautifulSoup
url = "http://trackinfo.com/dog-racelines.jsp?page=1&runnername=Ww%20Gloriaestefan"
myfile = open('base/basei/' + url[57:].replace("%20", " ").replace("%27","'") + '.txt','w+')
soup = BeautifulSoup(urllib2.urlopen(url).read())
for tr in soup.find_all('tr')[0:]:
tds = tr.find_all('td')
if len(tds) >=0:
print tds[0].text, ",", tds[4].text, ",", tds[7].text, ",", tds[12].text, ",", tds[14].text, ",", tds[17].text
myfile.write(tds[0].text + ','+ tds[4].text + "," + tds[7].text + "," + tds[12].text + "," + tds[14].text + "," + tds[17].text)
myfile.close()