What is the best way to save the comments collected from Facebook using Python?
Question: I'm collecting all the comments from some Facebook pages using Python and
Facebook-SDK.

Since I want to do Sentiment Analysis on these comments, what's the best way
to save these texts, such that it's not needed any changing in the texts?

I'm now saving the comments as a table and then as a CSV file.

    
    
    table.to_csv('file-name.csv')
    

But if I want to read this saved file, I get the following error:

    
    
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position ...
    

By the way, I'm working with the German Texts.


Answer: Have you tried this?

Set default encoder at the top of your code

    
    
    import sys
    reload(sys)
    sys.setdefaultencoding("ISO-8859-1")
    

or

    
    
    pd.read_csv('file-name.csv', encoding = "ISO-8859-1")
    

