It could be as simple as creating a table in VFP, saving the data in Word as a text file (comma or tab delimited etc.) and then using the "append from" commnd.
If you post an exaple of how the data is in word, I'm sure we could help you out.
This isn't pretty and it isn't well commented (but it's almost 1am!). As long as the spacing doesn't get too screwed-up in posting this should work. I tried to take care of data irregularity that might exist such as zip+4, no initials, and initials without a "." after them, but I can't solve for everything given only one example. Also, I assumed just one name would be OK since you only asked for one f/l name field.
The chr(48) to chr(57) is looking for a number in the data and assumes that if there isn't one that it has found a name... so it'll fail on "the 3rd".
At the end of the day, with data like what I assume you have, you'll need to check everything manually...
I suggest saving the original information for each address in an accompanying memo field.
Let me know if this helps
Brian
*************
SET SAFETY off
CREATE TABLE addtype (alldata c(180), addnumber n(5), datatype c(15), cfname c(30),cmi c(1), clname c(30),caddress c(50),ccity c(30),cstate c(15),czip c(10))
APPEND FROM sourcedata.txt TYPE sdf
sele addtype
scan
IF ALLTRIM(alldata)+" "#" " AND (CHR(48) $ alldata or CHR(49) $ alldata or CHR(50) $ alldata or CHR(51) $ alldata or CHR(52) $ alldata or CHR(53) $ alldata or CHR(54) $ alldata or CHR(55) $ alldata or CHR(56) $ alldata or CHR(57) $ alldata)=.f.
REPLACE datatype WITH "Name"
endif
endscan
GO 1
BROWSE nowait
VarCnt=1
DO WHILE EOF()=.f.
LOCATE FOR datatype="Name" AND RECNO()>=VarCnt
IF EOF()=.f.
SKIP 1
VarFrst1=LEFT(alldata,1)
IF VAL(VarFrst1)>=1 AND VAL(VarFrst1)<=9999
REPLACE datatype WITH "CityStateZip"
endif
REPLACE datatype WITH "StreetAdd1"
SKIP 1
VarLast4=RIGHT(ALLTRIM(alldata),4) && in case you have zip+4
IF VAL(VarLast4)>=1 AND VAL(VarLast4)<=9999
REPLACE datatype WITH "CityStateZip"
endif
IF VAL(VarLast4)<1
REPLACE datatype WITH "StreetAdd2"
SKIP 1
VarLast4=RIGHT(ALLTRIM(alldata),4) && in case you have zip+4
endif
IF VAL(VarLast4)>=1 AND VAL(VarLast4)<=9999
REPLACE datatype WITH "CityStateZip"
endif
endif
VarCnt=VarCnt+1
ENDDO
GO 1
SCAN
DO CASE
CASE DATATYPE="Name"
REPLACE clname WITH SUBSTR(ALLDATA,1,ATC(",",ALLDATA)-1)
IF OCCURS(".",ALLDATA)>0 && checks "." after for initial
REPLACE cfname WITH SUBSTR(ALLDATA,ATC(",",ALLDATA)+1,ATC(".",ALLDATA)-ATC(",",ALLDATA)-2)
REPLACE cmi WITH SUBSTR(ALLDATA,ATC(".",ALLDATA)-1,1)
endif
IF OCCURS(".",ALLDATA)=0 AND OCCURS(" ",ALLTRIM(substr(alldata,ATC(",",ALLDATA)+1,100)))>0&& checks "." after for initial and if there isn't one...
REPLACE cfname WITH SUBSTR(ALLTRIM(substr(alldata,ATC(",",ALLDATA)+1,100)),1,ATC(" ",ALLTRIM(substr(alldata,ATC(",",ALLDATA)+1,100)))-1)
REPLACE cmi WITH RIGHT(ALLTRIM(alldata),1)
ENDIF
CASE Datatype="StreetAdd1"
REPLACE caddress WITH ALLTRIM(alldata)
CASE datatype="StreetAdd2"
SKIP -1
Var4Add=ALLTRIM(alldata)
SKIP 1
REPLACE caddress WITH Var4Add+", "+ALLTRIM(alldata)
CASE Datatype="CityStateZip"
REPLACE CCity WITH left(alldata,ATC(",",ALLDATA)-1)
REPLACE CState WITH ALLTRIM(SUBSTR(alldata,ATC(",",ALLDATA)+2,3))
REPLACE CZip WITH ALLTRIM(SUBSTR(alldata,ATC(",",ALLDATA)+5,100))
ENDCASE
endscan
GO 1
VarNum=0
REPLACE addnumber WITH varnum
SCAN
IF RECNO()>1 AND Datatype#"Name"
REPLACE addnumber WITH varnum
ENDIF
IF datatype="Name"
VarNum=VarNum+1
REPLACE addnumber WITH varnum
ENDIF
ENDSCAN
SELECT dist addnumber,MAX(cfname) as cfname,max(cmi) as Cmi,MAX(clname) as clname,MAX(caddress) as Caddress, MAX(ccity) as ccity, MAX(cstate) as cstate,MAX(czip) as czip GROUP BY 1 FROM addtype INTO TABLE tempout
Brian's code above looks pretty good and should work. However, if it does not....then, see if you can transfer your contact information into excel and I can send you some code that you can use to pull information across into a VFP table.
Thanks for your feedback.I got it into a table that's useable in 9 fields,
but I am trying to parse the "comma" off that came along with the last name. . .ie. . . Adams, Jones, Smith, etc.
How can I get rid of the comma after the name in the field "cLname"?
Thanks for your add'l help
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.