[Tutor] Question about writing to Excel with slavic characters

Albert-Jan Roskam fomcl at yahoo.com
Mon Mar 5 20:20:45 CET 2012


Hi,

The R package foreign, in particular the read.spss function has some known problems reading spss system files. The memisc package also has a function to read .sav files. The big advantage of that function is that you can select rows and columns prior to actually reading the data into memory.

If you're just using R and Rpy to read .sav files, you could also consider using a Python program that I wrote a while ago:
http://code.activestate.com/recipes/577811-python-reader-writer-for-spss-sav-files-linux-mac-/
It runs on Windows, Mac and Linux and requires no installation of spss. I'd be interested to hear your experiences.

 
Regards,
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a 
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 


>________________________________
> From: Marko Limbek <marko.limbek at valicon.net>
>To: cwitts at compuscan.co.za 
>Cc: tutor at python.org 
>Sent: Monday, March 5, 2012 2:05 PM
>Subject: Re: [Tutor] Question about writing to Excel with slavic characters
> 
>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
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>To unsubscribe or change subscription options:
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120305/53e405f4/attachment.html>


More information about the Tutor mailing list