Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1161.Text merge -- How to merge odd lines from file1 and even lines from file2?

User: Aaron -- 2013-12-20          << 1160  1162 >>
Hits: 3919
Type: Text merge   
Search all Text merge examples
Description:
I would like to add the sequential line merge feature of script 977.For example; line 1 from Text 1, followed by line 2 from Text 2, followed by line 3 form Text 1, followed by line 4 from Text 2 etc. The merge effects only text in file Text 1.txt NOT contained in brackets.
Input Sample:
Text 1.txt 
 
Text 1 - Line 1 aaaa   bbb   ccc  ddd  eee (some text in brackets) 
Text 1 - Line 2 aaaa  bbbbbb c dd eee 
Text 1 - Line 3 aaaa bbb cc dd ee  fff 
Text 1 - Line 4 (more text in brackets) 
etc. 
 
Merge file is Text 2. 
 
Text 2.txt :  
 
Text 2 - Line 1.  
Text 2 - Line 2.  
Text 2 - Line 3.  
Text 2 - Line 4. 
etc. 
Output Sample:
Possible output: 
 
Text 1 - Line 1 aaaa   bbb   ccc  ddd  eee (some text in brackets) 
Text 2 - Line 2. 
Text 1 - Line 3 aaaa bbb cc dd ee  fff 
Text 2 - Line 4. (more text in brackets) 
Text 1 - Line 5 aaa bbb ccc d eee f ggg 
Text 2 - Line 6. (even more text in brackets) 
Text 1 - Line 7 a b ccc d e ff gg 
Text 2 - Line 8. (and more too in brackets) 
etc. 
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Assume file 1.txt and 2.txt are in d:\test\ folder 
1. ctrl-o open file 1.txt 
2. ctrl-h open 'replace' dialogue 
* set 'replace unit' to 'Line' 
* set 'unit number filter' to:  
* uncheck 'print unmatched unit' option 
* set 'replace with pattern' to: 
 
3. click 'replace', done. 
 
Note: if you want to remove everything in bracket in text 1.txt, just use following instead of $match: 
 

Screenshot 1:  Replace_Window


Similar Examples:
How to merge every 3 lines from file A and every 1 line from file B? (78%)
How to merge many files into one file? (62%)
How to merge for example 1000 files into 100 files? (62%)
How to merge two or more csv files with different columns into one file? (62%)
How to merge 4 lines to one according to given rules? (61%)
How to sort the lines in a text files by the order of line length? (61%)
How to copy same lines and combine different lines from 2 files? (60%)
How to get a N*M lines file, given a N-line file and a M-line file? (60%)

Check Demo of Text merge
Keywords:
brackets  sequential  odd lines  odd  bracket  odd line  remove everything  even line  even  tea  replace text with sequential number  remove odd lines text file  remove even lines of text  replace with sequential number  remove line only number  ctrl h replace brackets  sequential number text file  odd even