[BangPypers] Parsing data

Gora Mohanty gora at mimirtech.com
Sat Sep 17 08:03:48 CEST 2011


On Sat, Sep 17, 2011 at 9:56 AM, Ananya Sharma <as1438 at msstate.edu> wrote:
[...]

Could you explain the logic that you are trying to use in the code
below, because it is not making much sense. Also, is this a
homework problem?

> *Script-*
> *
> *
> f1=open('fileA','r')
> f2=open('fileB','r')
> a=""
> b=""
> for n in f1:
>    while not b.startswith(n):
>        b=f2.readline()
>    if len(a)>0:
>             print a

a is always "" above, so len(a) is always zero.

>    b=""
>    while not b.startswith(">"):
>       a=a+f2.readline()+"__"
[...]

You just set b to "", so the if conditional is never entered.

Regards,
Gora


More information about the BangPypers mailing list