I would have used

do shell script "sed -ne 's/^\\(..\\)" & zip & ".*$/\\1/p' zcta5.txt"

but the principle is the same.  You could also script TextEdit or
BBEdit...  The variations I tried with pure AppleScript were
excruciatingly slow, but I might just be doing it wrong.

There are also web services, e.g.
http://www.webservicex.net/uszip.asmx, but my attempts to call those
using AppleScript's SOAP functionality also failed.



On Thu, Mar 19, 2009 at 7:29 PM, Mark Lively <[log in to unmask]> wrote:
> All you really need is a file with the data and then grep for the zip code.
>
> The file I used was http://www.census.gov/tiger/tms/gazetteer/zcta5.txt
>
> set zip to "66603"
> do shell script "grep \"" & zip & " 5-Digit\"
> /Users/lively/Desktop/zcta5.txt | cut -c 1,2"
>
>
> On Mar 19, 2009, at 6:14 PM, Stockly, Ed wrote:
>
>> Is it possible, from a script, to determine the state from the zip code?
>>
>> I have a script that reads an address from a data base, but the address
>> doesn't contain a state. (In the past all the user's addresses were in
>> California, now they are covering listings other states.)
>>
>> (The user is working on getting the state inserted in the data in future
>> builds, but until then we have hundreds of addresses that need to be
>> fixed).
>>
>> ES
>>
>



-- 
Mark J. Reed <[log in to unmask]>