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

fread could parse timestamps requested as nanotime with dec=',' if they can first parse as POSIXct #6500

Open
MichaelChirico opened this issue Sep 16, 2024 · 1 comment
Labels

Comments

@MichaelChirico
Copy link
Member

MichaelChirico commented Sep 16, 2024

fread(text="t\n2023-10-12T06:53:53.123Z", colClasses="nanotime") # works
fread(text="t\n2023-10-12T06:53:53,123Z", colClasses="nanotime", sep=";") # does not

Originally posted by @ben-schwen in #6445 (comment)

#6445 (comment)

@MichaelChirico
Copy link
Member Author

This won't work as a general solution for {nanotime}, though, since we require first that the timestamp fits in POSIXct precision:

xp=as.POSIXct("2024-01-01 01:02:03.45678987654", "%Y-%m-%d %H:%M:%OS")
xn=as.nanotime("2024-01-01T01:02:03.45678987654Z")
all.equal(xn, as.nanotime(xp), tolerance=0)
# [1] "Mean relative difference: 5.516202e-17"

i.e., for string in file with too much precision, parsing first as POSIXct may eliminate precision:

fread("t\n2024-01-01T01:02:03.45678987654Z")
#                      t
#                 <POSc>
# 1: 2024-01-01 01:02:03

With that in mind I think we're best off not doing anything here -- better to require the user to change , to . in R and then parse nanotime, then to delete precision (which can't be recovered).

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

No branches or pull requests

1 participant