I have two files, namely:File1:CL1 AA  XX  YY  ZZ  SS \nCL2 3_b AAFile2:AA  string1AA  string23_b string3My expected output is:CL1 AA  string1CL1 AA  string2CL2 3_b string3CL2 AA  string1CL2 AA  string2For this I wrote a following code:import numpy as npprint(Reading Files...)header = open('File1', 'r')cl = header.readlines()infile = np.genfromtxt('File2', dtype='str', skip_header=1)new_array = []for j in range(len(infile)):    for row in cl:        element = row.split(\t)        ele_size = len(element)        for i in range(0, ele_size):            if np.core.defchararray.equal(infile[j,0], element[i]):                clust = element[0]                match1 = infile[j,0]                match2 = infile[j,1]                combo = \t.join([clust, match1, match2])                new_array.append(combo)np.savetxt('output.txt',new_array, fmt='%s', delimiter='\t')This generates the output I desire. But since the file has some  700000 lines in file2 and some 65000 clusters, it takes a huge time to iterate. Can anyone suggest an efficient way to parse it?Is it possible to keep first file as a list and the second file as a dictionary, and then iterate over key values?
Iterate list to map entries in Python
python;performance;csv;numpy;join