×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

INspects/revers function, address lines

INspects/revers function, address lines

INspects/revers function, address lines

(OP)
I have a program where the incoming address file is 50 bytes long. The problem is there is no delimiter other than space. 123 main st Orlando fl 30992 or PO BOX 23432 CASA GRANDE AZ 85122. I need to move 123 main st to addr1, orlando fl addr2 and 30992 to zip. I figured out how to get the zip out with:

move 0 to ws-tally, ws-data-length.
INSPECT FUNCTION REVERSE(CU-MAIL-ADDR) TALLYING WS-TALLY FOR LEADING SPACES
COMPUTE WS-DATA-LENGTH = LENGTH OF CU-MAIL-ADDR - ws-tally
MOVE CU-MAIL-ADDR(1:WS-DATA-LENGTH) TO WS-HOLD-ZIP1.

My question is what is the best way to read backwards from start of zip to get city/state (also accounting for 'SAN Diego' and move to addr2 and keep going back to move the rest to address1? Any ideas would be appreciated. I have looked through several scenarios on here, but they were'nt quite like this. Thanks!

RE: INspects/revers function, address lines

(OP)
Sorry I meant incoming address field is 50 bytes long.

RE: INspects/revers function, address lines

Personally, I think the best way of handling this is to UNSTRING your input into all its individual pieces and then examining each and STRING them back together into a properly formed address.

However, even that is not so simple, because there is no general way to be sure where the street address ends and the city name begins.

For example:

100 McCullogh Ave N Las Vegas, NV 89109

is it "McCullogh Ave N" in "Las Vegas", or is it "McCullogh Ave" in "N Las Vegas".

Not to mention multi-part street addresses. If you are strictly working with US addresses, you can put something together that works about 98% of the time, but if you have to deal with International addresses, you have a much bigger problem on your hands.

You might want to take a look at this thread209-1520795: Removing spaces form a Message and thread209-1436990: Pulling Addresses From Free Text Fields.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas

RE: INspects/revers function, address lines

(OP)
It is only US addresses and I have a list of all of the possible 2 word cities. Not sure how the unstring would work becuase there is not any kind of delimiter. I am reading backwards and have stripped out zip and state so far. Now I am at city.  

RE: INspects/revers function, address lines

You might have better luck this way:


1. Use a zip table like this:http://mappinghacks.com/data/

2. Build a table or index file from the zip code master.

3. Isolate the zip code from every string.

4. From the zip code file, get the city name and unstring
   your data into two fields with the city name as a
   delimiter. The first field should wind up as the street
   address. Note: you probably want to convert everthing to
   upper or lower case in both your data and the zip file.

This is not 100% reliable, but I am not sure anything is.

RE: INspects/revers function, address lines

(OP)
That's a great idea. Now I will only need to unstring the address, which will still take some work since, I do not have a delimter.  

RE: INspects/revers function, address lines

(OP)
Great idea Mrregan! Now I have zip and addr2, just have to figure out how to get addr1 w/o a delimiter.

123 main st or PO BOX 23432 CASA GRANDE AZ 85122.

RE: INspects/revers function, address lines

I like Mrregan's suggestion too! Just keep in mind that many ZIP codes have multiple city names associated with them.  For example, 77339 is both Kingwood, TX and Humble, TX. So as Mark said it's not 100% perfect but still pretty good.  I haven't checked whether the data file he provided includes alternate names such as these.

My original suggestion was unclear. Where I suggested UNSTRING'ing the input into multiple pieces, I meant using the spaces as delimiters.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas

RE: INspects/revers function, address lines

(OP)
mrregan wrote:
From the zip code file, get the city name and unstring
   your data into two fields with the city name as a
   delimiter. The first field should wind up as the street
   address. Note: you probably want to convert everthing to
   upper or lower case in both your data and the zip file.

Can anyone give me some pseudocode for this? Everything I have tried doesn't work. If I have the city, how can I use it as a delimiter? I tried to move the city to a delimiter but it does not work. Should I use perform varying or a unstring? Thanks everyone for your help!

RE: INspects/revers function, address lines

Good luck.  Several of my doctors' offices are on Calle de la Valencia (4 words)  I don't recall any 5-word street names, but I wouldn't at all be surprized to find one.

RE: INspects/revers function, address lines

You might consider parsing out the city, state, and zip and keep "the rest" as the "street address".

Suggest you run your actual data thru this and see how close you are.

RE: INspects/revers function, address lines

Count the number of characters in the city name before
encountering multiple spaces at the end of the city name.
Example: If you put the city name from the file in a 25 character field and the city name is Santa Fe, you should wind up with a count of 8. Now unstring your data delimited
by city-name (1:ws-count) into work-address, work-rest.

RE: INspects/revers function, address lines

(OP)
Thank you for everyone's input. I lucked out and the customer sent me a decent comma-delimited file that made it a snap!  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close