On 16/08/2016 5:36 PM, William ML Leslie wrote:
​What does something like this do for you?​

Before responding here is something which I think spells curtains for my Windows laptop.

http://stackoverflow.com/questions/878972/windows-cmd-encoding-change-causes-python-crash

I had a look at the csf file and it had somehow converted itself to utf-16. I suppose it was me but I didn't notice. I do remember saving as a few different encodings and I must have forgotten. It is now definitely utf-8 and shall remain so.

I'll be back

M




    with open(csvfile, "r", encoding='utf-16') as csv:

    Â Â Â  self.rows = csv.readlines()

    Â Â Â  for
    ​i, ​
    line in
    ​enumerate(​
    self.rows
    ​)​
    :

    Â Â Â Â Â Â Â  cells = line.split(",")

    Â Â Â Â Â Â Â  if i >= start:

    Â Â Â Â Â Â Â Â Â Â Â  print(', '.join(cells)
    ​.encode('cp1252', 'replace').decode('cp1252')​
    )

    Â Â Â Â Â Â Â  if i > finish:

    Â Â Â Â Â Â Â Â Â Â Â  break



--
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered under copyright law. You absolutely MAY reproduce any part of it in accordance with the copyright law of the nation you are reading this in. Any attempt to DENY YOU THOSE RIGHTS would be illegal without prior contractual agreement.


_______________________________________________
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug

_______________________________________________
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug

Reply via email to