Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: editing text file

Thread Tools

Re: editing text file

Tim Rowe
Posts: n/a
On Wed, 25 Jun 2003 18:05:53 +0200, ataraxia2500
<(E-Mail Removed)> 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:
>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.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox - Rich Text Editing: Cannot do a text bold...? deostroll Javascript 1 01-11-2008 09:49 PM
Editing particular lines of a text file. Shriphani Python 2 10-09-2007 11:56 AM
Editing a text file barjunk Ruby 3 04-30-2007 09:24 AM
Are you looking for high quality photo editing and video editing? C Programming 0 07-19-2006 12:32 PM
Opening a text file and editing its contents Perl Misc 6 01-16-2005 12:00 PM