Subject |
Re: Tab Delimited |
From |
Rob Rickard <rob@nospam.com.au> |
Date |
Thu, 03 Apr 2014 02:51:53 -0400 |
Newsgroups |
dbase.getting-started |
Thanks Mervyn
Sorry you could not sleep worry about the code :)
Why only 2 cups? My wife thinks coffee is in my veins with the amount she thinks I drink.
Once again thank you.
Regards Rob
Mervyn Bick Wrote:
> On Thu, 03 Apr 2014 07:38:52 +0200, Rob Rickard <rob@nospam.com.au> wrote:
>
> > Thank You Mervyn
> > Copies into the database beautifully BUT (there is always a but) it
> > appears the fields have an extra 2 characters in there when the field is
> > highlighted. The cursor is not at the end of the entry ie "abcdef " and
> > when you backspace it deletes "fe" etc when the cursor is not on the
> > character.
> > Does this make sense?
>
> Yes it does. Mind you it's not quite what I would have expected but there
> is a silly mistake in the coding so the program doesn't actually work as I
> had envisaged.
>
> The code was put together after a LONG day. It was past bedtime and I
> just didn't have the energy left to set up a test file for testing. It's
> funny how one's subconscious keeps churning even when one is sleeping. At
> one o'clock this morning I woke and had a DUH! moment. <g> Instead of
> discarding the TABs, the code was including a TAB separator in each field.
>
> It's a new day, I've had the second cup of coffee and the code below HAS
> been tested and it works. Bear in mind though the definition "Test data
> : the only data the application will work with." <g>
>
>
> Mervyn
>
>
> ******** Start of example code ********
> fIn = "whatever.txt"
>
> q = new query()
> q.sql = 'select * from whatever'
> q.active = true
>
> f = new file()
> f.open(fIn)
> for n = 1 to 5
> f.gets() //skip 5 lines
> next
> do while not f.eof()
> cRead= f.gets()
> q.rowset.beginAppend()
> for n = 1 to q.rowset.fields.size -1
> q.rowset.fields[n].value = substr(cRead,at(chr(9),cRead,n)+1;
> ,at(chr(9),cRead,n+1)-at(chr(9),cRead,n)-1) //deal with fields 2
> to second last field
> next
> q.rowset.fields[q.rowset.fields.size].value = ;
> substr(cRead,rat(chr(9),cRead)+1) //deal with last field
> q.rowset.save()
> enddo
> f.close()
> q.active = false
> ******* End of example code ********
|
|