On 2 April 2013 17:49, David Mitchell <d_mitchel...@hotmail.com> wrote: > Hi! > > How do I go through a text file, finding specific words/numbers/phrases and > edit them to say different things? I do not want to edit the text file, I > would rather open and read from the text file and write to a new file. > > I do NOT want to know how to replace a specific word with another every time > it appears. There are some "OFF" 's that i would like to change to "ON" 's > and some that I would like to change to "OPEN" for example. > > I am doing all this in Linux Fedora with gedit. It is a project assigned to > me from my boss and I'm just a co-op student so I could really use the help. > > Any help would be greatly appreciated!! > > Thanks, > > David
Can you give us some idea of your skill level, and perhaps some code that you've already tried? Your general approach will be something like open read_file open write_file read read_file into a list close read_file iterate over the list if you find a line you want to change make the change and write to write_file else write to write_file close write_file HTH, Bodsda _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor