#!/usr/bin/python3 import sys oldChannels={} oldChannelsData={} index=0 #first read the existing channeldata into dictionary for line in open(sys.argv[1]): channeldata =line.split(":",1)[0].strip() if len(channeldata)>0: oldChannels[channeldata]=index oldChannelsData[index]=line.strip() index+=1 #then read the new file for line in open(sys.argv[2]): channeldata =line.split(":",1)[0].strip() if len(channeldata)>0 and channeldata in oldChannels: # when the channel oldChannelsData[oldChannels[channeldata]]=line.strip() # update the channeldata o for counter in range(0,index): # dump the updated list print(oldChannelsData[counter])