[Python] How to prevent the apparition of NULL characters in my CSV file when the recording is...

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    Context: I'm doing some data processing/recording on an embedded Linux (Debian 12) with Python 3. Once processed, my data is written to a csv file by a dedicated thread. It currently works fine, however if the system has an electrical reboot NULL characters are written at the end of the file.

    My code is a basic:

    with open(self.path, "a", encoding="UTF-8") as file:
    writer = csv.writer(file, delimiter=CSV_DELIMITER)

    values = ...
    writer.writerow(values)


    How can I prevent these characters from appearing?

    Continue reading...

Compartilhe esta Página