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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing Address Data 1

Status
Not open for further replies.

fsub

Programmer
Feb 2, 2006
60
US
Hi,

I have the following data:
Sullivan Avenue
Santa Ana Drive
South Lake Shore Drive

I need to parse these into Street Name and Street Type such that output would be:
Street Name Street Type
----------------- ------------------
Sullivan Avenue
Santa Ana Drive
South Lake Shore Drive

Can someone give me the Crystal codes to perform this? Thanks
 
Hi,
if the data is always in that format and the type of street always the last part, then try these 2 formulas:

@StName
Split({DataField})[1] + ' ' + Split({DataField})[2]

@StType
Split({DataField})[3]




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
You need to use UBOUND to find the number of table elements. Write formulas for street and type, but adjusted on the basis of how many elements there were. So "Sullivan Avenue" would get an UBOUND value of 2, and you'd use the first for street and the second for type. "South Lake Shore Drive" would get an UBOUND value of 4, and you'd use the first, second and third for street, the fourth for type.

This can be done by a set of IF ... THEN ... ELSE statements. I don't think there's a simpler way.


[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
You could use formulas like these:

//{@Street Name}:
stringvar array x := split({table.address}," ");
x[ubound(x)]

//{@Street Type}:
whileprintingrecords;
stringvar array x := split({table.address}," ");
stringvar y := "";
numbervar i;
numbervar j := ubound(x);
for i := 1 to j-1 do(
y := y + x + " "
);
y

However, this won't work if you have an address like these, where the type is not the last element:

123 Smith Road NE
345 Allan Ave Apt 4

If there are cases like this, you would have to extract the types using another method.

-LB
 
Hi Folks,

lbass' codes worked like a gem. I've been working on this for a couple of days and would not have guessed to use such functions. I am sure that Turkbear and Madawc's codes would work just as well. I'll keep all of them for future use.

Thanks,
FSUB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top