我有两个文件,内容如下。我的问题是,在下面显示的代码中,如果 id 在 file1 和 file2 中匹配,那么如何匹配 file1 中的第二列和 file2 中对应的第二列直到 n 列..
def process(file):
pt = []
f=open(file)
for l in f:
parts=l.strip().split('\t')
if len(parts) < 3:
print 'error with either ur input file or field check parts'
break
else:
pt.append(parts)
return pt
arr1 = process(file1)
arr2 = process(file2)
for arr in arr1:
if arr[0] in arr2:
//then match arr1[1] with arr2[1] and so on and get the results
文件1:
ID674097256 voice tech department
ID674097257 NA NA
ID674097399 chat order processing department
文件2:
ID674097212 voice tech department
ID674097257 NA NA
ID674097399 chat new processing department