MACSCRPT Archives

March 2009

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Paul Berkowitz <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 19 Mar 2009 17:35:08 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (25 lines)
On 3/19/09 5:12 PM, "Mark J. Reed" <[log in to unmask]> wrote:

> 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.

I believe that Ed uses Excel. Ed, you could import a tab or comma-delimited
text file, if that's what it is, into excel 9you can even script that, but
you could just do it once in he UI and save the file as an .xls, and then
script Excel to search for any zip code in the appropriate column and get
the state code from its column in the same row. That would be fast, and
scripting Excel's formula to do the same lookup would be even faster -
instantaneous.

Like Mark, I would counsel against trying to do a "pure" AppleScript parsing
of the file, not using an application to do the heavy lifting: it will take
forever.

-- 
Paul Berkowitz

ATOM RSS1 RSS2