我有兩個文件,下面的內容如下。我的問題是,在下面的代碼 中,如果id匹配file1和file2,那麼如何匹配file1中的第二列和相應的第二列文件2至n列..在python中匹配數組的列
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
什麼是你的數據文件大小?數據線與一些命令? – fanlix
預期的輸出對我來說不是很明顯。你能否更清楚地解釋程序應該輸出什麼(給定file1和file2作爲輸入)? –