How to write symbol in csv file?
Question: I am trying to write username and symbol into my csv file from python code,but
whenever my loop come to that line it skip that record and write next record
in the file.Thank you in advance. Please help me in writing symbol into csv
file

For example: I want to write(Simeon Miller ✪)this name into name column.


Answer: Python doesn't magically skip records unless you explicitly code that.
Assuming the data is of type `unicode` you have to encode it before writing it
to the file. UTF-8 is a safe bet because that encoding can encode all possible
characters in `unicode` strings.

    
    
    #!/usr/bin/env python
    # coding: utf-8
    import csv
    
    
    def main():
        data = [[u'Simeon Miller ✪', 42], [u'Roger Rabbit', 4711]]
        with open('test.csv', 'wb') as csv_file:
            writer = csv.writer(csv_file)
            for name, number in data:
                writer.writerow([name.encode('utf-8'), str(number)])
    
    
    if __name__ == '__main__':
        main()
    

