Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

570.Text file splitter -- How to split a file into two parts according to the content of line?

User: editor -- 2010-07-22          << 569  571 >>
Hits: 4834
Type: Text file splitter   
Search all Text file splitter examples
Description:
How to split a file into two parts according to the content of line? 
I have a file containing PASS or FAIL in lines, I want to put all line with "PASS" in file1.txt, and all line with "FAIL" in file2.txt
Input Sample:
........... PASS 
.......FAIL 
..................PASS 
........PASS 
....FAIL
Output Sample:
===================== 
File1.txt: 
 
........... PASS 
..................PASS 
........PASS 
 
===================== 
File2.txt: 
 
.......FAIL 
....FAIL 
 
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open source text file 
2. ctrl-h open 'replace' window 
* set "Replace Unit" to "Line" 
* set "Search for pattern" to: 
 
* set "Replace with pattern" to: 
 
* uncheck "print unmatched unit" option 
* set "Output File" to  
* click "Replace", done! 
3. Activate Page0 by clicking "P0". 
4. Repeat step 2, but change "PASS" to "FAIL", and save to file2.txt, click "Replace", done! 
5. hold control key, use mouse select the 2 records at the middle of screen, right click and select "save to script", and save to my_split.rst. 
6. you can open the source file and run launch my_split.rst next time by open "Replace->Replace by script" menu
Download Script:  scripts/570.rst.zip

Screenshot 1:  Replace_Window


Similar Examples:
How to split a file into many files according to first letter of each line? (72%)
How to split a csv file into multiple files according to value of column B? (67%)
How to split a CSV file with Header according to value of  column B? (64%)
How to split a CSV file with Header according to value of a column? (64%)
How to extract from a file according to content of another file? (63%)
How to split a text file to different files according to first word in each line? (63%)
How to split a text file to different files according to first word in each line? (63%)
How to split a csv file according to the value of column A? (62%)

Check Demo of Text file splitter
Keywords:
screen  fail  control  pass  records  middle  replace by script  repeat  record  xxx  script to split text file into parts  split text according to content  text file two parts  split text file into two parts  split a text according to the time  file splitter text in parts  split text file according to content  split text file into two