Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One field into two 1

Status
Not open for further replies.

VictorBull

Programmer
Nov 22, 2002
2
GB
I have a database containing names and addresses.

One field contans the worrd LONDON followed by the postcode (in the US you call it zipcode.

I want to separate these into two fields, one with the town LONDON the second with the postcode which may be sometning like EC4Y 0HL

Please can anyone tell me the simplest way of doing this. The file is approx 19,000 records

Thanks in anticipation

Vic Bull

 
If it is absolutely consistant that London is the first 6 characters and the post code is variable, then I would probably use the substr() function and just parse out the post code. For example, assuming two fields of City and Post (Post is the exisiting field and City is new one):

var

tc tCursor
toParse string

endvar

if not tc.open(":myAlias:myTable.db")
then errorShow()
return
endif

if not tc.edit()
then errorShow()
return
endif

scan tc:

if tc."Post" <> "" ;skip blank records
then tc."City" = "LONDON"
toParse = tc."Post"
tc.Post = toParse.substr(8,(sizeEx(toParse)-8))
endif

endscan

tc.endEdit()
tc.close()

===============

You alternatively might use breakApart(), but I think this is simpler.

You may want to add in some error checking to check for blank records.



Mac :)

&quot;There are only 10 kinds of people in this world... those who understand binary and those who don't&quot;

langley_mckelvy@cd4.co.harris.tx.us
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top