[Tutor] updating a Csv file

Steven D'Aprano steve at pearwood.info
Wed Oct 20 11:47:42 CEST 2010

On Wed, 20 Oct 2010 08:05:06 pm Albert-Jan Roskam wrote:
> Hi all,
> How can I update a csv file? I've written the code below, but it does
> not work ("Error: line contains NULL byte").

Please copy and paste (DO NOT re-type, summarize, paraphrase or repeat 
from memory) the ACTUAL exception, including the traceback.

Based on the message shown completely out of context, I'm guessing that 
you're trying to stuff binary data into a CSV file, which needs plain 
text. But there doesn't seem to be anything in your code snippet that 
includes binary data, so I suspect that the code you are actually 
running is not the same as the code you think you are running.

Either that or you have modified string.letters to include things which 
are not letters. It might help if you mention what version of Python 
you're using, and the platform.

>            newLine = [ch for ch in string.letters[0:9]]

What's wrong with this?

newline = list(string.letters[0:9])

Steven D'Aprano

More information about the Tutor mailing list