ImportCSV picks up text content as date

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
Midiar
Posts: 11
Joined: Fri Mar 22, 2013 10:36 am

ImportCSV picks up text content as date

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: ImportCSV picks up text content as date

Post by larsa »

Hello

This is fixed in update 5.20.54. Text that not starts with a digit is never parsed as a date.
Lars Arvidsson, Axolot Data
Midiar
Posts: 11
Joined: Fri Mar 22, 2013 10:36 am

Re: ImportCSV picks up text content as date

Post by Midiar »

Thanks a lot! Worked like a charm.
Post Reply