"Spyros Charonis" wrote
I have a file with the following contents:
from header1
abcdefghijkl
mnopqrs
tuvwxyz
*
from header2
poiuytrewq
lkjhgfdsa
mnbvcxz
*
My string processing code goes as follows:
file1=open('/myfolder/testfile.txt')
scan = file1.readlines()
string1 = ' '
for line in
This snipped also works - may be there is a better solution -
', '*']
>>> s = ''
>>> for line in lines:
line = line.rstrip('\n')
if line.startswith('>from header'):
continue
elif line.startswith('*'):
s = s + '\n'
else:
s = s + line
>>> s
'abcdefghijklmnopqrstuvwxyz\npoiuytrewqlkjhgfdsamnbvcxz\
concatenate the entire thing together, including the "*".
Once you have that as a single string, use string.split('*') and you will
have your two strings.
On Mon, May 16, 2011 at 9:51 AM, Spyros Charonis wrote:
> I have a file with the following contents:
>
> >from header1
> abcdefghijkl
> mnopq
I have a file with the following contents:
>from header1
abcdefghijkl
mnopqrs
tuvwxyz
*
>from header2
poiuytrewq
lkjhgfdsa
mnbvcxz
*
My string processing code goes as follows:
file1=open('/myfolder/testfile.txt')
scan = file1.readlines()
string1 = ' '
for line in scan:
if line.startswith('>