Python Forum
Replace lines from one .txt file to another
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replace lines from one .txt file to another
#8
(Jun-22-2017, 06:04 PM)Tumppi Wrote: there is many "blocks" at the text files where I need copy and paste between the lines?
If here is not any easier method, i Will try this. Can you give example how i read two input files and write one?

How would you do it with paper & pencil? Think how to go forward step by step, how you can decide which line to look at next, which line to copy or not copy. As of now, I don't understand exactly what you want python to do, and it won't either. You need to be much more specific. Maybe make a small but complete example like you did above but with the new information that file2 can be longer as well, what would be the desired output, and how do you get there?
Reply


Messages In This Thread
RE: Replace lines from one .txt file to another - by Kebap - Jun-22-2017, 08:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replace a text/word in docx file using Python Devan 4 3,887 Oct-17-2023, 06:03 PM
Last Post: Devan
  Need to replace a string with a file (HTML file) tester_V 1 815 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Replace columns indexes reading a XSLX file Larry1888 2 1,034 Nov-18-2022, 10:16 PM
Last Post: Pedroski55
  Delete multiple lines from txt file Lky 6 2,400 Jul-10-2022, 12:09 PM
Last Post: jefsummers
  How to do a mass replace within a CSV file? cubangt 9 5,579 May-09-2022, 06:52 PM
Last Post: snippsat
  I get an FileNotFouerror while try to open(file,"rt"). My goal is to replace str decoded 1 1,453 May-06-2022, 01:44 PM
Last Post: Larz60+
  failing to print not matched lines from second file tester_V 14 6,283 Apr-05-2022, 11:56 AM
Last Post: codinglearner
  Extracting Specific Lines from text file based on content. jokerfmj 8 3,162 Mar-28-2022, 03:38 PM
Last Post: snippsat
  Importing a function from another file runs the old lines also dedesssse 6 2,664 Jul-06-2021, 07:04 PM
Last Post: deanhystad
  [Solved] Trying to read specific lines from a file Laplace12 7 3,643 Jun-21-2021, 11:15 AM
Last Post: Laplace12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020