Open Expurple opened 5 months ago
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.
I tried to use
as_datetime()
to find and parse dates in anxlsx
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 callingas_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 returnsNone
forDataType::Int
andDataType::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()
andas_time()
.