<div dir="ltr">In the code below I am trying to read 2 files f1 and f2 , extract some data from them and then trying to write them into a single file that is 'nf'.<br><div><br>import cv<br>f1 = open(r"Z:\modules\Feature_Vectors_300.arff")<br>
f2 = open(r"Z:\modules\Feature_Vectors_300_Pclass.arff")<br>nf = open(r"Z:\modules\trial.arff", "w")<br><br><br>for l in f1:<br>    sp = l.split(",")<br>    <br>    if len(sp)!= 12:<br>
        continue<br>    else:<br>        ix = sp[0].strip()<br>        iy = sp[1].strip()<br>        print ix, iy<br>        <br>       for s in f2:<br>            st = s.split(",")<br>    <br>            if len(st)!= 11:<br>
                continue<br>            else:<br>                clas = st[10].strip()<br>        <br>             print ix, iy, clas<br>             print >> nf, ix, iy, clas<br><br>f1.close()<br>f2.close()<br>nf.close()<br>
<br><br></div><div>I think my code is not so correct , as I am not getting desired results and logically it follows also but I am stuck , cannot find a way around this simple problem of writing to a same file.. Please suggest some good pythonic way I can do it.. <br>
<br><br></div><div>Thanks in Advance <br></div></div>