0

Sir need some help.

I think it's an easy task but I cannot configure it. I want to compare two text files & output the differences in quoted text.

I tried this post-https://stackoverflow.com/a/28216365/12031112 & it's working fine, but I cannot get output in quoted text.

def compare(File1,File2):
    with open(File1,'r') as f:
        d=set(f.readlines())


    with open(File2,'r') as f:
        e=set(f.readlines())

    open('file3.txt','w').close() #Create the file

    with open('file3.txt','a') as f:
        for line in list(d-e):
           f.write(line)
File1 = 'Updatedfile1.txt'
File2 = 'Rawfile2.txt'
compare(File1,File2)


for example: In text file it was without a quote & each line ie

boofx.com

uooos.com

jiooq.com

But want output like below in file3.txt:

"boofx.com",
"uooos.com",
"jiooq.com",
"zcrcd.com",
"jeoce.com",
"xcoxc.com",
"cdfaq.com",

& in the last line without a comma(,). Any solution will be highly appreciated.

rnso
  • 23,686
  • 25
  • 112
  • 234
SAHU
  • 15
  • 2

0 Answers0