Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve detectDates. closes #288 #291

Merged
merged 4 commits into from
Jan 3, 2022

Conversation

JanMarvin
Copy link
Collaborator

Hackish attempt to fix #288

This PR checks if there is a numeric value, at a position, where we already expect a string of this type "yyyy-mm-dd". For whatever kind of reason, we end up here, with a numeric value in #288. Most likely due to the date being a POSIXct. Therefore most likely the fix is at the wrong position and should be somewhere else. For this minimal test file it should not matter, though with larger files we might waste a lot of time testing the conversion.

@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2021

Codecov Report

Merging #291 (5b5340f) into master (d5c38ed) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
+ Coverage   67.70%   67.71%   +0.01%     
==========================================
  Files          34       34              
  Lines        8897     8900       +3     
==========================================
+ Hits         6024     6027       +3     
  Misses       2873     2873              
Impacted Files Coverage Δ
src/write_file.cpp 90.34% <100.00%> (+0.20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b8b88c...5b5340f. Read the comment docs.

src/write_file.cpp Outdated Show resolved Hide resolved
@JanMarvin JanMarvin added this to the merge after next release milestone Dec 6, 2021
@JanMarvin JanMarvin changed the base branch from master to development January 3, 2022 21:45
@JanMarvin JanMarvin merged commit 0bde8cf into ycphs:development Jan 3, 2022
@cha-petersumm
Copy link

I still have issue, with a file that was simply written by openxlsx and then read back again (so Excel has never been near it).

write.xlsx(CVAD_list, "CVAD list.xlsx")
CVAD_list2 <- read.xlsx("CVAD list.xlsx")
CVAD_list3 <- read.xlsx("CVAD list.xlsx", detectDates = T)

Error message from the third line above is as follows:

Error reading date:
44696.5
row: 59
col: 6
Error: basic_string::substr: __pos (which is 8) > this->size() (which is 7)

There's nothing obviously odd about cell F59.

I'm happy to create an example that I can post if it would be useful.

packageVersion("openxlsx")
[1] ‘4.2.5.2’

@JanMarvin
Copy link
Collaborator Author

Hi @cha-petersumm , you can have a look at openxlsx2. The changes here went into the development branch, but never to CRAN.

@cha-petersumm
Copy link

cha-petersumm commented Apr 13, 2023

Hi @cha-petersumm , you can have a look at openxlsx2. The changes here went into the development branch, but never to CRAN.

Thanks. That does appear to load from CRAN now, and it does fix the problem with dates. Great work!

As per https://cran.r-project.org/web/packages/openxlsx2/index.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

read.xlsx(detectDates = TRUE) failing
3 participants