-2

I wanted to know if there's a way to ignore it if the latin1 can't encode and ignore the errors?

This when I'm going to save to a csv file

enter image description here

  • 3
    Always provide code as a text, as a minimum reproducible code. For your problem I suggest you reading file first so you can [try this answer](https://stackoverflow.com/questions/24616678/unicodedecodeerror-in-python-when-reading-a-file-how-to-ignore-the-error-and-ju) – jupiterbjy Jun 14 '22 at 17:26
  • What's the purpose to use `latin1` if this encoding doesn't contain all chars you need? Choose encoding which fits your requirements. – Olvin Roght Jun 14 '22 at 17:27
  • I have a system here that only accepts with latin1 Olivin Roght – jt_sobrinho Jun 14 '22 at 17:39
  • 3
    [Why should I not upload images of code/data/errors when asking a question?](https://meta.stackoverflow.com/a/285557/19170534) – Andreas Violaris Jun 14 '22 at 17:51

1 Answers1

3

You can pass the keyword argument errors='ignore' to the DataFrame.to_csv method to ignore encoding/decoding errors. More info can be found in the documentation.

jprebys
  • 2,469
  • 1
  • 11
  • 16