Removing specific text from every line
<p>I have a txt file with this format:</p>

<pre><code>something text1 pm,bla1,bla1
something text2 pm,bla2,bla2
something text3 am,bla3,bla3
something text4 pm,bla4,bla4
</code></pre>

<p>and in a new file I want to hold:</p>

<pre><code>bla1,bla1
bla2,bla2
bla3,bla3
bla4,bla4
</code></pre>

<p>I have this which holds the first 10 characters for example of every line. Can I transform this or any other idea?</p>

<pre><code>with open('example1.txt', 'r') as input_handle:
    with open('example2.txt', 'w') as output_handle:
        for line in input_handle:
            output_handle.write(line[:10] + '\n')
</code></pre>
