Subject Re: importing text file programmatically
From Mervyn Bick <invalid@invalid.invalid>
Date Tue, 8 Feb 2022 22:17:59 +0200
Newsgroups dbase.getting-started
Attachment(s) custodian.prgcustodian.DBF

On 2022/02/08 17:34, Emeka Ossai wrote:
> Oh thank you Mervyn
>
> I have attached the files

The "out of line" problem in field8 was caused by the field definition
for field7 being numeric(5,2) instead of numeric(6,2).

Don't use "date" as a fieldname.  It is a SQL reserved word and it will
cause problems sooner or later.  I've changed it to DDATE.  You will
need to recreate the indexes.

Attached is a little program to append from the text file and then
populate the ddate and cdate fields.

Mervyn.


cFile = 'custodian0207.txt'
use custodian
append from &cFile sdf
go top
scan
   cDate = ltrim(rtrim(field10))
   replace ddate with new date(val(substr(ltrim(field10),1,4)),val(substr(ltrim(field10),5,2))-1,val(substr(ltrim(field10),7,2)))
   replace cdate with dtoc(ddate)
endscan
use