Paradox Community

Items in pnews.paradox-programming

Subject:Re: Action after csv import
Date:Wed, 15 Nov 2017 05:03:04 -0500
From:"Kevin Baker" <shcsbaker@gmail.com>
Newsgroups:pnews.paradox-programming
I realize now I had tunnel vision on my first post.  I need to allow the 
user to do this match.  Here's a better attempt of what I'm trying to 
implement.  Some of my customers use paypal, givelify, etc to accept online 
donations.  These 3rd party services allow them to export this data to a csv 
file.  The field order from each of these companies varies, so once I get 
the csv file imported into the temp table, I need to offer them a way to 
match the fields in Table A to Table B.  It's also possible for my customers 
to use a 3rd party company I've never heard of, so allowing this process to 
be a little dynamic will hopefully keep me from having to re-write my code.

Hope this makes a little more sense

"Côme"  wrote in message news:5a0b6de1$1@pnews.thedbcommunity.com...

Le 14/11/2017 à 20:55, Kevin Baker a écrit :
> Hi Everyone,
>
> I'm trying to determine if this is possible.  I need to import a csv file, 
> which I know how to do.  Once the csv file is imported into a temp table 
> (Table A), I need to transfer the records from the Table A into another 
> table (Table B), however I need to match up the fields from Table A to 
> Table B.  For example the first field in Table A is a Date field, which 
> would be the 4th field in Table B.  I would do the copy from Table A to 
> Table B via tcursor.
>
> I would use enumFieldNames to get the field names from Table A, but really 
> not sure how to move forward from this point.
>
> I was hoping someone might have done this in the past or could point me in 
> the right direction.
>
> Thanks,
> Kevin

Hi

You could simply use, in a scan loop for instance,
tc.CopyToArray(myArray) to copy the initial data of the record in an
array (or a dynarray) and then, in the same scan loop, with a second
TCursor write in your destination table from the array.

If the fields have the same name in the two tables you would use a
dynarray (the field name will be the index) [to be honest you don't even
need the array in this case simply use tc2.Fieldname = tc1.Fieldname],
if not, an array (the index will be the position of the field, 1,2...)
and then tc2.Fieldname = myArray[2] for example to copy the second field
of tc1 in tc2.Fieldname.

Another possible way is to run an insert query (in SQL or QBE) but with
the TCursor approach you can offer a progress bar for example. You have
more control with TCursor. 


Copyright © 2004 thedbcommunity.com