Search code examples
pythonencodingrdatalatin

How to change encoding (using latin encoding) in pyreadr Python


I am trying to read an RData file in Python with the package pyreadr, but the default encoding is 'utf-8'. I need to change it into 'latin' because when I launch the following command

pyreadr.read_r('Input/myFile.RData')

I get the following error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 30: invalid start byte

The pyreadr.read_r function does not have the encoding input parameter, so I do not know how to fix it. Any help ?


Solution

  • Unfortunately it is currently not possible. From the README in the known limitations section:

    Cannot read RData or rds files in encodings other than utf-8.

    This feature would need to be suported by the underlying C library librdata. You can open an issue in librdata suggesting to implement this feature, together with a sample file.