मेरे द्वारा आयात किए जा रहे ट्वीट्स का एक गुच्छा इस मुद्दे पर है कि वे कहां पढ़ते हैं
b'I posted a new photo to Facebook'
मैं bइंगित करता हूं कि यह एक बाइट है। लेकिन यह समस्याग्रस्त साबित हो रहा है क्योंकि मेरी CSV फ़ाइलों में जो मैं लिखता हूं, वह bदूर नहीं जाती है और भविष्य के कोड में हस्तक्षेप कर रही है।
क्या bमेरे पाठ की पंक्तियों से इस उपसर्ग को हटाने का एक सरल तरीका है ?
ध्यान रखें, मुझे लगता है कि utf-8 में पाठ को एन्कोडेड करने की आवश्यकता है या tweepy को वेब से खींचने में परेशानी है।
मैं यहां लिंक सामग्री का विश्लेषण कर रहा हूं:
https://www.dropbox.com/s/sjmsbuhrghj7abt/new_tweets.txt?dl=0
new_tweets = 'content in the link'
कोड प्रयास
outtweets = [[tweet.text.encode("utf-8").decode("utf-8")] for tweet in new_tweets]
print(outtweets)
त्रुटि
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-21-6019064596bf> in <module>()
1 for screen_name in user_list:
----> 2 get_all_tweets(screen_name,"instance file")
<ipython-input-19-e473b4771186> in get_all_tweets(screen_name, mode)
99 with open(os.path.join(save_location,'%s.instance' % screen_name), 'w') as f:
100 writer = csv.writer(f)
--> 101 writer.writerows(outtweets)
102 else:
103 with open(os.path.join(save_location,'%s.csv' % screen_name), 'w') as f:
C:\Users\Stan Shunpike\Anaconda3\lib\encodings\cp1252.py in encode(self, input, final)
17 class IncrementalEncoder(codecs.IncrementalEncoder):
18 def encode(self, input, final=False):
---> 19 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
20
21 class IncrementalDecoder(codecs.IncrementalDecoder):
UnicodeEncodeError: 'charmap' codec can't encode characters in position 64-65: character maps to <undefined>