1

So, I am trying to write some information into a csv file encoded in utf-8 but it is not letting me citing the following error:

ERROR:root:Error: There're some errors in the lambda funtion process - 'ascii' codec can't encode character '\xa1' in position 602: ordinal not in range(128)

the writer I am using in order to convert a list of values into data rows is:

writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)

I tried installing unicodecsv and using it but it didn't play nice with some of the characters.

If I try to do a list comprehension for every row written by the writer usinfg the following function y end up with b's in every entry in the csv which should not be since I really need it to be plaintext.

paula.em.lafon
  • 553
  • 2
  • 6
  • 15
  • 2
    Show us the data you're attempting to write that is causing the error. – John Gordon Jul 08 '19 at 22:35
  • Maybe this is your problem: https://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20 –  Jul 08 '19 at 22:45
  • If you're using Python 3, there's no need to use `unicodecsv`. Instead, you need to make sure the `output` stream is opened with `encoding='utf8'`. – lenz Jul 09 '19 at 08:59
  • Please add a bit more code, showing how you open the file and write the rows. – Martin Evans Jul 11 '19 at 08:50

0 Answers0