Jump to content

vinatabamk

Lurker
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Serf

About vinatabamk

  • Rank
    Serf
  1. i Have file1.txt: check=<http://photobucket.com/98a267d32b056fb0a5c8c07dd4c35cc5.jpg> show Image! http://lincoln.com/view/5453443333/flower1.jpg http://lincoln.com/view/2454354344/flowe2.jpg http://lincoln.com/view/3434343434/flower3.jpg +++++++++ check=<http://phtobucket.com/004_8N9FEWFZD7ECJC6.jpg> show Image! http://lincoln.com/view/5454545455/candy1.jpg http://lincoln.com/view/3453453453/candy2.jpg http://lincoln.com/view/3454545455/candy3.jpg +++++++++ ... ... And more content as above and i have file2.txt http://lincoln.com/view/4148476844/flower1.jpg http://lincoln.com/view/4148476994/flowe2.jpg http://lincoln.com/view/4148501374/flower3.jpg http://lincoln.com/view/4148633524/candy1.jpg http://lincoln.com/view/4148538064/candy2.jpg http://lincoln.com/view/4148537824/candy3.jpg http://kashi.com/view/414865/flower1.jpg http://kashi.com/view/634353/flower2.jpg http://kashi.com/view/234234/flower3.jpg http://kashi.com/view/2323423/candy1.jpg http://kashi.com/view/3465345/candy2.jpg http://kashi.com/view/2354234/candy3.jpg ==> I want replace file2.txt into file1.txt : if filename exists in file1 but not in file2: remove line have filename in file1.txt (filename is flower2.jpg, candy2.jpg...) else if filename exists in file1 and in file2: the version in file2 replaces the line in file1 else if filename exists in file2 but not in file1: do nothing add the links with the domaine name "http://kashi.com" from file2.txt in a section "More link view" before "+++++++++" and output as: check=<http://photobucket.com/98a267d32b056fb0a5c8c07dd4c35cc5.jpg> show Image! http://lincoln.com/view/4148476844/flower1.jpg http://lincoln.com/view/4148476994/flowe2.jpg http://lincoln.com/view/4148501374/flower3.jpg http://lincoln.com/view/4148476324/flower4.jpg http://lincoln.com/view/4148494685/flower5.jpg http://lincoln.com/view/4148626615/flowew6.jpg You Can VIEW More Link ! More Link: http://kashi.com/view/414865/flower1.jpg http://kashi.com/view/6344353/flower2.jpg http://kashi.com/view/234234/flower3.jpg http://kashi.com/view/6543534/flower4.jpg http://kashi.com/view/2342342/flower5.jpg http://kashi.com/view/234234/flower6.jpg +++++++++ check=<http://phtobucket.com/004_8N9FEWFZD7ECJC6.jpg> show Image! http://lincoln.com/view/4148633524/candy1.jpg http://lincoln.com/view/4148538064/candy2.jpg http://lincoln.com/view/4148537824/candy3.jpg http://lincoln.com/view/4148562565/candy4.jpg http://lincoln.com/view/4148562035/candy5.jpg More Link: http://kashi.com/view/23423423/candy1.jpg http://kashi.com/view/345345/candy2.jpg http://kashi.com/view/234234/candy3.jpg http://kashi.com/view/3434342/candy4.jpg http://kashi.com/view/234234234/candy5.jpg +++++++++ ... ... ... i Tried this code but not enough condition above: def file_merge(file1,file2): file1contents = list() file2contents = list() file1=open('file1.txt','r') for line in file1: line= line.replace('\n','') line= line.split('/') file1contents.append(line) file1.close() file2=open('file2.txt','r') for line in file2: line = line.replace('\n','') line = line.split('/') file2contents.append(line) file2.close() file3contents=file1contents for x in file2contents: for y in file1contents: if x[-1] == y[-1] and x[2]==y[2]: file3contents[file3contents.index(y)]=x file3contents.append(['More Link VIew']) for x in file2contents: for y in file1contents: if x[-1] == y[-1] and x[2]== 'kashi.com' and y[2]=='lincoln.com': file3contents.append(x) file3 = open('out.txt','w') for line in file3contents: file3.write(str('/'.join(line))+'\n') file3.close() file_merge('file1.txt','file2.txt') Every Help ME Complete Code !. Thanks !
×