"Albert-Jan Roskam" <fo...@yahoo.com> wrote

I tried updating the old values with new values of exactly the same length (10 characters),
but that didn't work either

newLine = [ch for ch in string.letters[0:9]])
Error: line contains NULL byte

Id,NaamInstelling,Naam3,Straat,HuisNr,Postcode,Plaats,dummy

There are 8 field headingss here but newline is a list with 9 values...

MQrrSzDboW,XWvxiqlrEp,ERQewcVYva,ppBXnpeCOs,HTmVvHRVhH,KHvjNHIYeM,bcEMrYPmuB,w

And this has 8 fields, but they are not all single characters,
nor are they all 10 characters so I'm not sure how you think
you are writing out the same number of characters?

...Should I instead just open one file, write to
another, throw away the original and rename the new file? That seems
inefficient.

This is by far the most common design pattern. It is safer and allows
you to roll back to the old version in the event of an error (if you save
the original as a .bak or similar).

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to