Hi, I am new in python and programming basically.
I have a code that compare 2 files by the first column and prints a file with the common lines. But i need it to compare the first 3 columns and print the file.
I kind of have and idea of changing the if to be something like:
f1line=f1.readlines()
for i in f1line
if (i.split()[1]==f2line[x].split()[1] and i.split()[2]==f2line[x].split()[2]
I am just not sure if that would be right and if it will work when the files don't have the same number of lines
import sys
f1=file(sys.argv[1])
f2=file(sys.argv[2])
d1 ={}
for l in f1:
c=l.split()[0]
d1[c]=l
d2 ={}
for l in f2:
c=l.split()[0]
d2[c]=l
for i in d1.keys():
cc=len(i)
if d2.has_key(i):
print i, d1[i][cc+1:].strip(),d2[i][cc+1:].strip()