vnmabus / rdata

Reader of R datasets in .rda format, in Python
https://rdata.readthedocs.io
MIT License
40 stars 2 forks source link

Read RDS data #17

Closed soheila-sahami closed 2 years ago

soheila-sahami commented 2 years ago

Is it possible to improve the package in a way that it can read rds data too? Thanks in advance!

vnmabus commented 2 years ago

It turns out that it is kinda trivial to add. Check #18 and tell me if you can open your files with it.

soheila-sahami commented 2 years ago

Thanks for the update.

I could open the file and parse it, but the convert method throws an error in line 140: AttributeError: 'RData' object has no attribute 'attributes' RData object is created in line 544 using the 'data' parameter which is not an instance of RData. It is the same if I set the default_encoding or not.

My test code is as follows:

import rdata parsed = rdata.parser.parse_file(file_path) converted = rdata.conversion.convert(parsed, default_encoding="utf8") converted_df = pd.DataFrame(converted.get("df_final"))

vnmabus commented 2 years ago

Sorry, but I can't replicate the error. Do you have some example RDS file that I can check?

soheila-sahami commented 2 years ago

I have tried it with the test data that I shared with you, and got the same error. Could you please try it?

vnmabus commented 2 years ago

I can't reproduce the error. For me it seems to work: imagen

You said that the error is in the conversion step. Can you print the parsed structure?

vnmabus commented 2 years ago

Were you able to parse it, @soheila-sahami ?

soheila-sahami commented 2 years ago

Hi, Thanks for the update. I tried it after the latest changes you did and it works as expected. convert method returns a df and no need to call converted.get("df_final"), as was explained in a comment. Mega thanks!

vnmabus commented 2 years ago

Closed by #18.