I have two text files:
myfile1:
sports1
sports2
sports3
sports4
sports5
sports6
sports7
sports8
myfile2:
sports1 Cricket
sports2 golf
sports3 Hocky
sports4
sports5 Chess
sports6 Snooker
sports7 Foosball
sports8 Tampts
From the two files above, f column one in myfile1
matches with column one in myfile2
then it should print both columns of myfile2
.
The awk one-liner below works, but I am looking for a similar one in Python.
awk 'NR==FNR{c[$1]++;next};c[$1]' myfile1 myfile2