[Tutor] Question about writing to Excel with slavic characters

Marko Limbek marko.limbek at valicon.net
Mon Mar 5 14:05:10 CET 2012


Thank you!

That was easy. Now I have another problem.
I use RPy and read the spss database with method read.spss inside a
nested R code in Python, that looks like that:


import rpy

r("""

library(foreign)

baza <- read.spss(""" + analysis[0] + """)

print(baza$demo_izob0)

""")

Now when my text data labels in spss have slavic characters, they are
not recognised and output is something like that:

stiriletna srednja �ola
nedokon�ana osnovna �ola


What should I do here?


Thanks a lot,


Marko




On Mon, Mar 5, 2012 at 1:46 PM, Christian Witts <cwitts at compuscan.co.za> wrote:
> On 2012/03/05 02:37 PM, Marko Limbek wrote:
>
> Hi everyone.
>
>
> I am new to list and few months old to Python. I am writing some text
> to Excel and I open the new book and try to write to the book and the
> save it using
>
> book.save
>
> Now when I write slavic characters in the text to Excel (č, š, ž, for
> instance 0xc5), I get an error, I can't save it.
> I have declared appropriate encoding
>
> # -*- coding: utf-8 -*-
> # coding=<utf-8>
> #!/E:/Python
>
> and those characters appear normally in the code, but there seems to
> be the problem with the function book.save.
> Does anyone have any ideas, what would be the problem and how to solve
> it? Some additional encoding or some changes or parameters to the
> book.save method?
>
> Is that the right forum for my question?
>
>
> Thank you,
>
> Marko
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
> What package are you using to create your Excel workbook ?
> If it's xlwt you can set your encoding type when you create your workbook
> book = xlwt.Workbook(encoding="utf-8")
> --
>
> Christian Witts
> Python Developer


More information about the Tutor mailing list