Compare and replace - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Compare and replace (/thread-16967.html) |
Compare and replace - veltor88 - Mar-22-2019 Bonjour, I have 2 files .txt i am trying to find a script for compare et replace between 2 files. I heard about python but i dont know how Example txt1: Quote:2000 Yay+0 txt1: Quote:2000 Arc court+0 But i have more 7000 lines to translate Thanks you in advance RE: Compare and replace - gontajones - Mar-22-2019 With Python you can handle files content very easily. But I don't think that someone here will do it for you. What have you done so far? Post some code lines here to attract more people to help you. RE: Compare and replace - veltor88 - Mar-22-2019 Thanks for you answer This is what i want to do, replace line of text 2 to text 1 RE: Compare and replace - gontajones - Mar-22-2019 You can start playing around with files like this Comparing two Files.. Then post your code here. RE: Compare and replace - snippsat - Mar-22-2019 (Mar-22-2019, 12:12 PM)gontajones Wrote: I heard about python but i dont know howPython is one of there more easy programming languages to start with,but it still take some effort to learn the basic If you just want to solve a task and not learn Python,it's more a post for jobs section of forum. To give a example that almost should solve it,try writing to file yourself. 1.txt:
with open('1.txt') as f: for line in f: if 'foo bar' in line: line = line.replace('foo bar', 'red car') print(line.strip()) else: print(line.strip())
RE: Compare and replace - gontajones - Mar-22-2019 (Mar-22-2019, 01:28 PM)snippsat Wrote:(Mar-22-2019, 12:12 PM)gontajones Wrote: I heard about python but i dont know how I do know how! |