Page 1 of 1

Pull mailing addresses from 1,000 html files

Posted: Sat Jan 03, 2004 6:35 pm
by Plaz
I am very new to textpad, but have talked with those who use it, and they are die-hard fans... claiming textpad can do amazing things. I am sure this is true, but do not know how to accurately tell textpad what I need it to do.

If there is a textpad guru out there that really knows their stuff, I would be most grateful for a "how-to" on this one:

What I need to do is extract the addresses out of about 1,000 html files that are saved on my local harddrive. They are pretty logical the way they are set up, so I'm positive textpad can do this, but I don't know how, myself.

Say for instance the code looks like this:

Code: Select all

Name of contact person</td><td width="60%" bgcolor="#EEEEEE" align=left><font face=arial size=2>
Bob Stark</td></tr>
<tr><td width="40%" align=right><font face=arial size=2>
Contact's mailing address</td><td width="60%" align=left><font face=arial size=2>
22517 Iverson Lane
<br>Suite 43</td></tr>
<tr><td width="40%" bgcolor="#EEEEEE" align=right><font face=arial size=2>
Contact City</td><td width="60%" bgcolor="#EEEEEE" align=left><font face=arial size=2>
Pensacola</td></tr>
<tr><td width="40%" align=right><font face=arial size=2>
Contact State</td><td width="60%" align=left><font face=arial size=2>
Florida</td></tr>
<tr><td width="40%" bgcolor="#EEEEEE" align=right><font face=arial size=2>
Contact Zip</td><td width="60%" bgcolor="#EEEEEE" align=left><font face=arial size=2>
10549</td></tr>
but sometimes, there may be only one line in the address, like this:

Code: Select all

Name of contact person</td><td width="60%" bgcolor="#EEEEEE" align=left><font face=arial size=2>
Bob Stark</td></tr>
<tr><td width="40%" align=right><font face=arial size=2>
Contact's mailing address</td><td width="60%" align=left><font face=arial size=2>
22517 Iverson Lane</td></tr>
<tr><td width="40%" bgcolor="#EEEEEE" align=right><font face=arial size=2>
Contact City</td><td width="60%" bgcolor="#EEEEEE" align=left><font face=arial size=2>
Pensacola</td></tr>
<tr><td width="40%" align=right><font face=arial size=2>
Contact State</td><td width="60%" align=left><font face=arial size=2>
Florida</td></tr>
<tr><td width="40%" bgcolor="#EEEEEE" align=right><font face=arial size=2>
Contact Zip</td><td width="60%" bgcolor="#EEEEEE" align=left><font face=arial size=2>
10549</td></tr>
There is lots of code both before and after the addresses in each file, and some files may contain no addresses at all.

what I want the results to look like, if it looked at the two "files" above, would be an appended list like this:

Bob Stark
22517 Iverson Lane
Suite 43
Pensacola, Florida 10549

Bob Stark
22517 Iverson Lane
Pensacola, Florida 10549

etc..

Even better than the above "list style" results, would be if the addresses could be put into a comma delimited database style textfile, like this:


Name, AddressOne, AddressTwo, City, State, Zip
Bob Stark, 22517 Iverson Lane, Suite 43, Pensacola, Florida, 10549
Bob Stark, 22517 Iverson Lane, , Pensacola, Florida, 10549

I'm sure this would take someone who REALLY truly knows what they're doing in textpad... and that person is not me :D

Any insight on this would be very appreciated.
If textpad can't do it... can you point me to something that can?

Thanks in advance!

Posted: Sat Jan 03, 2004 9:45 pm
by s_reynisson
Please keep in mind that 1. the data you posted is very small, so you
might want to check the results for 1000 html files, I would! and 2. this is
only one way of about 100 to do this... :wink:

1. start by joining the html files into one larger file at command prompt,
copy *.html combin.doc, after that TP is ready to do some work on the
result file combin.doc
2. strip tags, standard TP macro
3. find contact, mark all, delete marked lines
4. find ^ *\n, replace with nothing, delete empty lines
5. find (.+)\n(.+)\n(.+)\n(.+)\n(.+)\n([0-9]{5})\n
replace all \1,\2,\3,\4,\5,\6\n
6. find (.+)\n(.+)\n(.+)\n(.+)\n([0-9]{5})\n
replace all \1,\2,,\3,\4,\5\n

Note: For steps 4 to 6 I have used POSIX regular expression syntax, which
can be selected from the Editor page of the Preferences dialog box.
Note also: When working with a full html file be sure to delete other lines not
included in your sample, ie. add steps as needed before step 5.