Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

977.Text merge -- How to make random line by line sequential merge of multiple text files?

User: Aaron -- 2012-07-23          << 976  978 >>
Hits: 3531
Type: Text merge   
Search all Text merge examples
Description:
How to make random line by line sequential merge of multiple text files? 
choose only one sequential line from each text file.  
For example; line 1 from text 4, followed by line 2 from text 3, 
followed by line 3 from text 1,  followed by line 4 from text 2, etc.  
A line must be chosen from each file before the process is  repeated. 
 
 
Input Sample:
- CONTENT OF Text1.txt : 
 
Text1 - Line1. 
Text1 - Line2. 
Text1 - Line3. 
Text1 - Line4. 
etc. 
 
- CONTENT OF Text2.txt : 
 
Text2 - Line1. 
Text2 - Line2. 
Text2 - Line3. 
Text2 - Line4. 
etc. 
 
- CONTENT OF Text3.txt : 
 
Text3 - Line1. 
Text3 - Line2. 
Text3 - Line3. 
Text3 - Line4. 
etc. 
 
- CONTENT OF Text4.txt : 
 
Text4 - Line1. 
Text4 - Line2. 
Text4 - Line3. 
Text4 - Line4. 
etc. 
Output Sample:
Text4 - Line1. 
Text2 - Line2. 
Text1 - Line3. 
Text3 - Line4. 
Text1 - Line5. 
Text4 - Line6. 
Text3 - Line7. 
Text2 - Line8. 
etc.  
 
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Assume: 
1. the diretory of your files are: d:\test 
2. all .txt files in folder d:\test may be randomly selected. 
3. there are 100 lines in each file 
 
Procedure: 
1. ctrl-h open 'replace' dialogue 
2. set 'replace with pattern' to: 
 
3. click 'advanced' tab 
* set 'run following at the beginning of replace' to: 
 
4. click 'replace', done. 
5. ctrl-s save result to file. 
 
Note: 
1. the real folder should be in place of "d:\\test\\", and double backslash should be used as delimiter 
2. the real number of line should be in place of $L=100, you can also use $L=count(file_content('d:\\test\\Text1.txt'),'\n') instead

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to make line by line sequential merge of multiple text files? (94%)
How to move the last line to the beginning for multiple text files? (70%)
How to replace a word only one time in multiple text files? (65%)
How to delete the second column in multiple text files? (61%)
How to extract unique ip addresses from multiple text/html files? (61%)
How to shuffle specified lines in multiple text files? (60%)
How to remove all the lines that with odd line number for multiple files? (60%)
How to extract the last non-blank line from multiple text files? (59%)

Check Demo of Text merge
Keywords:
mapfile  repeated  sequential  sequential merge  make random  randomly select  grep  repeat  tea  line sequ  replace text with sequential number  replace with sequential number  sequential number text file  repeated lines  merge sequential lines  random merge  3 lines random txt file  multiple txt merge