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

Feature request: format-aware version of as_datetime() #400

Open
Expurple opened this issue Feb 2, 2024 · 1 comment
Open

Feature request: format-aware version of as_datetime() #400

Expurple opened this issue Feb 2, 2024 · 1 comment

Comments

@Expurple
Copy link
Contributor

Expurple commented Feb 2, 2024

I tried to use as_datetime() to find and parse dates in an xlsx sheet, but it also coerces numbers that aren't formatted like dates. I'd really like to see a smarter, format-aware version of this method that doesn't do this.

I've read some similar issues and I know that doing this correctly is hard. But I found that simply matching DataType::DateTime(..) | DataType::DateTimeIso(..) before calling as_datetime() gives the right result for my use case. Do you approve a new method that has the same logic for these two variants and returns None for DataType::Int and DataType::Float? If yes, how would you name it? After you answer, I can implement and submit it myself.

And we should probably do the same thing for as_date() and as_time().

@tafia
Copy link
Owner

tafia commented Feb 6, 2024

I'd say this is more a documentation issue here. Lot of excel files show floats or strings instead of dates and there cannot be a one size fits all solution I'm afraid.

Matching over 2 variants is simple enough that we may leave it as it is. Or else add another to_datetime as opposed to as_datetime which encompasses some conversion.

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

No branches or pull requests

2 participants