ImportCSV picks up text content as date
Posted: Tue Aug 11, 2015 9:27 am
When I try to import a csv file with the following line in it (anonymised), the second cell is picked up as a date.
That happens in ImportCSVInt, in the last check before defaulting to a text field. SysUtils.TryStrToDateTime is used to check if we have a datetime cell, but TryStrToDateTime skips any non-numeric characters before trying any real date conversion.
I think this is unexpected behaviour for an import routine. TryStrToDateTime should not be used to check if it is a datetime cell. (XLSUtils5.TryStrToDateTime looks like it uses the same routine, so it would not be suitable as a replacement.)
Input:
Result (simple text paste from the worksheet):
I am using XLSReadWriteII 5.20.53
In D6 this scanning past non-numeric characters is not done, but it looks like it happens in all versions from D2010 onwards. I am testing in XE8.
I hope you agree with me that it is a bug that should be fixed, or am I missing an obvious workaround?
::tor
That happens in ImportCSVInt, in the last check before defaulting to a text field. SysUtils.TryStrToDateTime is used to check if we have a datetime cell, but TryStrToDateTime skips any non-numeric characters before trying any real date conversion.
I think this is unexpected behaviour for an import routine. TryStrToDateTime should not be used to check if it is a datetime cell. (XLSUtils5.TryStrToDateTime looks like it uses the same routine, so it would not be suitable as a replacement.)
Input:
Code: Select all
1091;torgeir25.11@gmail.com;429;2.000 ;0000013540
Code: Select all
1091 25.11.2015 429 2 13540
In D6 this scanning past non-numeric characters is not done, but it looks like it happens in all versions from D2010 onwards. I am testing in XE8.
I hope you agree with me that it is a bug that should be fixed, or am I missing an obvious workaround?
::tor