vnmabus / rdata

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

Add reader for ascii files #34

Closed trossi closed 6 months ago

trossi commented 6 months ago

This PR adds parser for ascii files.

See also #31.

A minimal test is also added for reading the following files generated in R:

data = list(1.1, 2L, 3+4i, NA, 'aä')
save(data, file='test_ascii_v2.rda', ascii=TRUE, compress=FALSE, version=2)
save(data, file='test_ascii_v3.rda', ascii=TRUE, compress=FALSE, version=3)
saveRDS(data, file='test_ascii_v2.rds', ascii=TRUE, compress=FALSE, version=2)
saveRDS(data, file='test_ascii_v3.rds', ascii=TRUE, compress=FALSE, version=3)

These files are generated both on Linux and Windows. Windows-R seems to use \r\n line ending for rds files but \n for rda files (tested on R 4.3.2).

@vnmabus Could you review? Do you think that this kind of testing would be sufficient?

codecov-commenter commented 6 months ago

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (2b927cb) 91.04% compared to head (122f847) 90.08%. Report is 1 commits behind head on develop.

Files Patch % Lines
rdata/parser/_parser.py 75.00% 5 Missing :warning:
rdata/parser/_ascii.py 94.44% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #34 +/- ## =========================================== - Coverage 91.04% 90.08% -0.97% =========================================== Files 7 8 +1 Lines 1106 1170 +64 =========================================== + Hits 1007 1054 +47 - Misses 99 116 +17 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

trossi commented 6 months ago

@vnmabus I rebased the branch to fix conflicts and fixed some mypy issues found locally. The mypy CI action seems not be working, see a log here.

trossi commented 6 months ago

Line ending of _parser.py had changed in develop branch, so I rebased this PR again (it seemed clearer approach than resolving merge conflict with the two files with different line endings). Style issues by ruff are fixed also.

trossi commented 6 months ago

@vnmabus Thanks for reviewing and merging!