查找两列

import os
import pandas
dir = "C://Downloads"
myfile = os.path.join(dir,"idmapping_selected.tab")
#myfile = os.path.join(dir,"test.txt")
fw = open(os.path.join(dir,"map"),"w")

num = 0
with open(myfile) as infile:
    for line in infile:
        line_arr = line.split('\t')
        if(line_arr[3]==""):
            continue
        if ";" in line_arr[3]:
            pro_arr = line_arr[3].split(";")
            for item in pro_arr:
                #print item.strip()+"\t"+line_arr[0]+"\n"
                fw.write(item.strip()+"\t"+line_arr[0]+"\n")
                num=num+1
        else:
            #print line_arr[3]+"\t"+line_arr[0]+"\n"
            fw.write(line_arr[3]+"\t"+line_arr[0]+"\n")
            num=num+1
        if num%100000==0:
            print num

dic = dict()



你可能感兴趣的:(查找两列)