On 16/08/2016 11:27 AM, William ML Leslie wrote:
On 16 August 2016 at 11:01, Mike Dewhirst <[email protected]> wrote:
If anyone can point me to the appropriate advice for resolving the error
below I would be most appreciative. Really very appreciative.
I think I understand Unicode in theory and have reread a lot of articles
including ...
The article we recommend for getting a good grasp is
http://nedbatchelder.com/text/unipain.html or Joel Spolsky's article
on the subject.
print("%s" % cells)
Bit of a red flag. print("%s" % x) seems a funny way to write print(x).
You're right. It is just a habit I picked up somewhere. I'll rejig that.
As it happens print(x) made no difference.
cells = list(line)
This is a list of characters, not a list of comma-separated values.
Perhaps you wanted cells = line.split(',')
I did but the output didn't change.
or the CSV module which
will handle quoted values too.
I'll have look at that.
I have tried utf-8 encoding each line and that gets past the error but just
produces a set of chars a snippet of which below [2].
Decoding that as utf-8
reproduces the error as might be expected. I have also tried decoding as
utf-16 and encoding it as utf-8 but that didn't work either.
As for the encode error, this tells you that it is trying to convert
some text into bytes. I'm not sure if it is sys.stdout.write that is
failing to do this, or the %.
It looks like both but I'm sure it is Windows stuffing me up with that
cp850 in the traceback.
What is the value of sys.stdout.encoding at this point?
It is just a waypoint. I just wrote the class init and wanted to prove
it produced data I can use before writing the necessary data mapping and
import methods. Once it is working I'll probably put a conditional in
there so it only produces stdout output when unit testing.
Thanks William, I'll look at the csv module after trying out Paul's
suggestion to look at csvkit
Cheers
Mike
_______________________________________________
melbourne-pug mailing list
[email protected]
https://mail.python.org/mailman/listinfo/melbourne-pug