Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: editing text file (http://www.velocityreviews.com/forums/t318839-re-editing-text-file.html)

Tim Rowe 06-25-2003 04:39 PM

Re: editing text file
 
On Wed, 25 Jun 2003 18:05:53 +0200, ataraxia2500
<messageboardfan1@yahoo.com> wrote:

> is there a function that can search for specific words in a text file (kind
>of like grep) and change them?
>say in my text file there's a line such as:
>[myvalue]=X
>
>and my function would search the line [myvalue] and replace X by Y.
>
>any suggestions?
>
>thanx in advance


Use a for line in file.readlines() loop and the re module for your
matching. Though, to be honest, if that's all you want to do then
Python is probably an overkill; there's probably a port of sed for
your platform, whatever platform it is, and I reckon that would be the
appropriate level of tool.


All times are GMT. The time now is 05:30 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.