0

I have a file:

a;b;c
d;x;f
g;h;z

And I need to remove lines from file that contains x (result contains first and last line). How to achieve this?

The code logic is using appending mode and detects upon other file in read mode. Does that means I have to switch open modes upon detection, closing it and again opening appending more?

Code I have can add to file:

f1 = open(file1, 'a')
f2 = open(file2, 'r'):
    line = ''
    (reading logic..)
    if 'x' in line:
        # need here to remove the line

Or is there other way without using open? I'm using Python 2.6.6.

Poli
  • 77
  • 1
  • 11

0 Answers0