exceptionfactory commented on PR #9379: URL: https://github.com/apache/nifi/pull/9379#issuecomment-2414693743
> @exceptionfactory I just found this helpful [tutorial](https://www.myonlinetraininghub.com/excel-date-and-time#:~:text=When%20you%20look%20at%20a,decimal%20portion%20is%20the%20time.) which explains how dates and times are stored in Excel. Based on this information I believe we can provide better inferences when the cell type is numeric and is date formatted. If its a whole number we know its date, if its a fraction we know its a time and if its a whole number with a fraction then its a timestamp. Hence lines 81-84 in `StandardCellFieldTypeReader` can be expanded to incorporate this logic to identify the most precise type (DATE, TIME or TIMESTAMP). > > e.g. (Which probably would look better incorporated in its own method) > > ``` > if (DateUtil.isCellDateFormatted(cell)) { > final double numericCellValue = cell.getNumericCellValue(); > if (numericCellValue > 0 && numericCellValue < 1;) { > dataType = RecordFieldType.TIME.getDataType(); > } else { > final long roundedCellValue = (long) numericCellValue; > if (roundedCellValue == numericCellValue) { > dataType = RecordFieldType.DATE.getDataType(); > } else { > dataType = RecordFieldType.TIMESTAMP.getDataType(); > } > } > } > ``` Thanks for the background and example @dan-s1, that is very helpful. I will incorporate that approach and include you as a co-author on the commit. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
