KeyError: u'\ufeff'
delta-s-shadow opened this issue · 1 comments
Not sure if this is an error on my end, or something I don't understand.
Background:
I'm using a Ukrainian word list to mine tweets from twitter for research. I have it saved as a cPickle file which I upload and able to print into python without any problems.
Problem:
I receive the following error and can't figure out what is going on to is throwing it. Any help would be appreciated.
Traceback (most recent call last):
File "<pyshell#29>", line 1, in <module>
execfile("twittersearchloc.py")
File "twittersearchloc.py", line 25, in <module>
for tweet in ts.search_tweets_iterable(tso):
File "C:\Python27\lib\site-packages\twittersearch-1.0.1-py2.7.egg\TwitterSearch\TwitterSearch.py", line 204, in search_tweets_iterable
self.search_tweets(order)
File "C:\Python27\lib\site-packages\twittersearch-1.0.1-py2.7.egg\TwitterSearch\TwitterSearch.py", line 305, in search_tweets
self._start_url = order.create_search_url()
File "C:\Python27\lib\site-packages\twittersearch-1.0.1-py2.7.egg\TwitterSearch\TwitterSearchOrder.py", line 232, in create_search_url
url += '+'.join([quote_plus(i) for i in self.searchterms])
File "C:\Python27\lib\urllib.py", line 1310, in quote_plus
return quote(s, safe)
File "C:\Python27\lib\urllib.py", line 1303, in quote
return ''.join(map(quoter, s))
KeyError: u'\ufeff'
How I tried to solve the problem:
I figured the non ascii formart was throwing it off, but trying to decode or encode it into different formats didn't work.
Definitely an encoding error. I guess you are using Python2k, right?
The easiest way would be to use Python3k. Every string in python 3 is unicode by default. So this might actually solve your problem.