Page 1 of 1

ImportCSV picks up text content as date

Posted: Tue Aug 11, 2015 9:27 am
by Midiar
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:

Code: Select all

1091;torgeir25.11@gmail.com;429;2.000 ;0000013540
Result (simple text paste from the worksheet):

Code: Select all

1091	25.11.2015	429	2	13540
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

Re: ImportCSV picks up text content as date

Posted: Wed Aug 12, 2015 10:07 am
by larsa
Hello

This is fixed in update 5.20.54. Text that not starts with a digit is never parsed as a date.

Re: ImportCSV picks up text content as date

Posted: Wed Aug 12, 2015 8:57 pm
by Midiar
Thanks a lot! Worked like a charm.