Discussion:
Convert a data Table
(too old to reply)
Dorian Chalom
2005-06-21 20:56:22 UTC
Permalink
What is the best way to convert this data table:
Document Recip Name
Doc1 Sue Adams
Doc1 Sue Adelt
Doc1 Sue, Nancy Brigs
Doc1 Sue, Nancy Carlton
Doc2 Sue Bolts

To this Data Table:
Document Recip Name
Doc1 Sue Adams
Doc1 Sue Adelt
Doc1 Sue Brigs
Doc1 Nancy Brigs
Doc1 Sue Carlton
Doc1 Nancy Carlton
Doc2 Sue Bolts
Mark McCasland
2005-06-22 00:40:01 UTC
Permalink
You do not say what version of VFP you use, but here is how I would do it in
VFP7 or later. I do not recall if it can be done this way in prior versions.

USE Table_Name
locate for at(',', recip) > 0
do while not eof()
scatter name loRecord
loRecord.Recip = alltrim(getwordnum(recip, 2, ','))
replace recip with alltrim(getwordnum(recip, 1, ','))
append blank
gather name loRecord
locate for at(',', recip) > 0
enddo
Post by Dorian Chalom
Document Recip Name
Doc1 Sue Adams
Doc1 Sue Adelt
Doc1 Sue, Nancy Brigs
Doc1 Sue, Nancy Carlton
Doc2 Sue Bolts
Document Recip Name
Doc1 Sue Adams
Doc1 Sue Adelt
Doc1 Sue Brigs
Doc1 Nancy Brigs
Doc1 Sue Carlton
Doc1 Nancy Carlton
Doc2 Sue Bolts
Dorian Chalom
2005-06-22 01:20:22 UTC
Permalink
The number of names coming from recip could be any number of names. And I
am using VFP 6.0

Thanks for your help.
Post by Mark McCasland
You do not say what version of VFP you use, but here is how I would do it in
VFP7 or later. I do not recall if it can be done this way in prior versions.
USE Table_Name
locate for at(',', recip) > 0
do while not eof()
scatter name loRecord
loRecord.Recip = alltrim(getwordnum(recip, 2, ','))
replace recip with alltrim(getwordnum(recip, 1, ','))
append blank
gather name loRecord
locate for at(',', recip) > 0
enddo
Post by Dorian Chalom
Document Recip Name
Doc1 Sue Adams
Doc1 Sue Adelt
Doc1 Sue, Nancy Brigs
Doc1 Sue, Nancy Carlton
Doc2 Sue Bolts
Document Recip Name
Doc1 Sue Adams
Doc1 Sue Adelt
Doc1 Sue Brigs
Doc1 Nancy Brigs
Doc1 Sue Carlton
Doc1 Nancy Carlton
Doc2 Sue Bolts
Olaf Doschke
2005-06-22 18:17:47 UTC
Permalink
Post by Dorian Chalom
The number of names coming from recip could be any number of names. And I
am using VFP 6.0
With vfp6 you can
SET LIBRARY TO foxtools.fll

and then also have Getwordnum().

It's not hard to make that code Mark
gave you work with more than 2 Names.

Bye, Olaf.
Mark McCasland
2005-06-23 02:06:36 UTC
Permalink
Use the foxtools library like Olaf said, then use try this (test it out
first and modify as needed) --

USE Table_Name
locate for at(',', recip) > 0
do while not eof()
lnKount = GETWORDCOUNT(recip, ',')
scatter name loRecord
lcString = loRecord.Recip
replace recip with alltrim(getwordnum(lcString, 1, ','))
FOR lnI = 2 to lnKount
loRecord.Recip = alltrim(getwordnum(lcString, lnI, ','))
append blank
gather name loRecord
ENDFOR
locate for at(',', recip) > 0
enddo
Post by Dorian Chalom
The number of names coming from recip could be any number of names. And I
am using VFP 6.0
Thanks for your help.
Post by Mark McCasland
You do not say what version of VFP you use, but here is how I would do
it
Post by Dorian Chalom
Post by Mark McCasland
in
VFP7 or later. I do not recall if it can be done this way in prior versions.
USE Table_Name
locate for at(',', recip) > 0
do while not eof()
scatter name loRecord
loRecord.Recip = alltrim(getwordnum(recip, 2, ','))
replace recip with alltrim(getwordnum(recip, 1, ','))
append blank
gather name loRecord
locate for at(',', recip) > 0
enddo
Post by Dorian Chalom
Document Recip Name
Doc1 Sue Adams
Doc1 Sue Adelt
Doc1 Sue, Nancy Brigs
Doc1 Sue, Nancy Carlton
Doc2 Sue Bolts
Document Recip Name
Doc1 Sue Adams
Doc1 Sue Adelt
Doc1 Sue Brigs
Doc1 Nancy Brigs
Doc1 Sue Carlton
Doc1 Nancy Carlton
Doc2 Sue Bolts
Loading...