Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread CSV Import Table missing first column of data
Tue, Nov 28 2023 5:48 AMPermanent Link

Adam Brett

Orixa Systems

I have a weird problem.

I run a fairly simple IMPORT TABLE script:

IMPORT TABLE "WebOrderPreliminary"
 FROM "Test-Nov27.csv"
 IN STORE "Imports"
 FORMAT DELIMITED
 ENCODING AUTO
 DELIMITER CHAR #9
 QUOTE CHAR '"'
 DATE FORMAT 'yyyy-mm-dd'
 TIME FORMAT 'hh:mm:ss n' AM LITERAL 'AM' PM LITERAL 'PM'
 DECIMAL CHAR '.'
 BOOLEAN TRUE LITERAL 'True' FALSE LITERAL 'False'
 USE HEADERS

Using the attached CSV file.

The import is to a table which has column-names that duplicate the names of the header-row of the CSV file.

The importation occurs perfectly, except that the FIRST COLUMN (order_id) is not imported. In the "WebOrdersPreliminary" table, the order_id is NULL.

If I re-order the data in the CSV file so that the "order_date" is the first piece of data in the CSV file "order_date" then shows NULL in the table.

So I am losing the first column of data whatever I do.

I have done countless IMPORT TABLE processes in the past without this happening before.

Can anyone give me any ideas?!



Attachments: Test-Nov27.csv
Tue, Nov 28 2023 6:19 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


I generally start by suspecting the data. In the file you supplied in my hex editor it starts with hex ef bb bf () - doesn't look right

Roy Lambert
Tue, Nov 28 2023 10:08 AMPermanent Link

Adam Brett

Orixa Systems

Dear Roy

Thanks for this, really helpful.

I have never got into things like hex editors. I probably need to.

The output is coming from a web-service I don't have much control over.

I guess I may have to try to parse the file in Delphi ...
Wed, Nov 29 2023 2:47 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


Just bunging the three characters into DDG I get this link https://en.wikipedia.org/wiki/Byte_order_mark it may be possible for you to tell the producing program to not include it. If not you should only have to bother about the first three characters so easy enough to strip. It may even be as simple as changing teh ENCODING to force unicode.

Roy Lambert
Wed, Nov 29 2023 2:49 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


If you really want to do it all in Delphi its not to difficult - you could use my nlhStrTable to give you a starter for 10 - should be in the binaries.

Roy Lambert
Image