[Tutor] newbie search and replace

Ron Nixon nixonron@yahoo.com
Mon Jan 27 14:58:06 2003


--0-899984948-1043697382=:96837
Content-Type: text/plain; charset=us-ascii


I have a file with several thousand address in it with different spellings of "st", "street" "road", "rd" "lane", "ln"

I want to go in a standardize all the spellings. The file looks like this below

 

100 Broad Street

50 Apple LN

24 Dirckson St.

439 Bullock RD

342 Nash Road

I tried something like this

addr = open('c://address.txt')

import string
addr = open('c://address.txt')
addrN = addr.readlines()
addrN.replace('LN', 'Lane')

I got an error message back. Can someone tell me what am I doing wrong here and how to correct the problem to get the results I want?

 

Ron



---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
--0-899984948-1043697382=:96837
Content-Type: text/html; charset=us-ascii

<P>I have a file with several thousand address in it with different spellings of "st", "street" "road", "rd" "lane", "ln"</P>
<P>I want to go in a standardize all the spellings. The file looks like this below</P>
<P>&nbsp;</P>
<P>100 Broad Street</P>
<P>50 Apple LN</P>
<P>24 Dirckson St.</P>
<P>439 Bullock RD</P>
<P>342 Nash Road</P>
<P>I tried something like this</P>
<P>addr = open('c://address.txt')</P>
<P>import string<BR>addr = open('c://address.txt')<BR>addrN = addr.readlines()<BR>addrN.replace('LN', 'Lane')</P>
<P>I got an error message back. Can someone tell me what am I doing wrong here and how to correct the problem to get the results I want?</P>
<P>&nbsp;</P>
<P>Ron</P><p><br><hr size=1>Do you Yahoo!?<br>
<a href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Yahoo! Mail Plus</a> - Powerful. Affordable. <a href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Sign up now</a>
--0-899984948-1043697382=:96837--