pyreadr
pyreadr copied to clipboard
error: The file contains an unrecognized object
import pyreadr
result = pyreadr.read_r('infile.rds')
---------------------------------------------------------------------------
LibrdataError Traceback (most recent call last)
<ipython-input-46-82b33438231f> in <module>
1 import pyreadr
2
----> 3 result = pyreadr.read_r('infile.rds')
/projects/sysbio/projects/rojin/anaconda3/envs/scvi/lib/python3.6/site-packages/pyreadr/pyreadr.py in read_r(path, use_objects, timezone)
45 if not os.path.isfile(path):
46 raise PyreadrError("File {0} does not exist!".format(path))
---> 47 parser.parse(path)
48
49 result = OrderedDict()
/projects/sysbio/projects/rojin/anaconda3/envs/scvi/lib/python3.6/site-packages/pyreadr/librdata.pyx in pyreadr.librdata.Parser.parse()
/projects/sysbio/projects/rojin/anaconda3/envs/scvi/lib/python3.6/site-packages/pyreadr/librdata.pyx in pyreadr.librdata.Parser.parse()
LibrdataError: The file contains an unrecognized object
From the Readme, known limitations section:
S4 Objects and probably other kind of objects,
including those that depend on non base R
packages (Bioconductor for example) cannot
be read. The error code in this case is as follows:
"pyreadr.custom_errors.LibrdataError:
The file contains an unrecognized object
How to solve it? thank you @ofajardo
No solution at the moment. The issue is tracked here: https://github.com/WizardMac/librdata/issues/16
I have run into this same issue and as far as I can tell, my data has no S4 objects or any unusual object types. Any thoughts on what else could be the issue?
Please share the file. If I cannot reproduce it I cannot debug.
Unfortunately the data contains personal health information and cannot be shared. I have an alternative versions of the data (same object types) that does not run into issues. If I am able to create the a version with fake data that reproduces the issue I will share. Thanks.
I think I was able to resolve the issue. Seems to have come down to two things. It had an issue with the object being type "data.frame". However, as a "data.table" "data.frame" I no longer had the error. However, after this was resolved, the kernel would always reset. I found that the data had factor variables with NA coded as a level. This seemed to cause the kernel to reset