Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1117.Text file parser -- How to randomly select one line from each paragraph?

User: Aaron -- 2013-08-22          << 1116  1118 >>
Hits: 3556
Type: Text file parser   
Search all Text file parser examples
Description:
1. Source text contains multiple paragraph blocks with different number of lines per block.  
 
2. Each paragraph block is separated by a blank line.  
 
3. If paragraph block contains more than one line then randomly choose only one line to output for that block.  
 
4. If paragraph block contains only one line then original line is sent to output. 
 
5. Blank line between paragraph blocks remains. 
 
Input Sample:
"Aaaaa aaaa a aaaa aaa aaa." 
 
Bbbbb bbbb bbb bbbbb. Cccccc c ccc ccc cccc, cccc.  
Ddd dddd dddd. Eeee e eee eeee. 
 
"Fffff f fff?" Gggg ggggg g gggg. "Hhhh hh h hhh, hhhhh."  
 
Iiii iii iii i. 
etc.
Output Sample:
Possible Output example: 
 
"Aaaaa aaaa a aaaa aaa aaa." 
 
Cccccc c ccc ccc cccc, cccc.  
 
"Fffff f fff?"   
 
Iiii iii iii i. 
etc.
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open text file 
2. ctrl-h open 'replace' dialogue 
* set 'replace unit' to "paragraph" 
* set 'replace with pattern' to: 
 
3. click 'replace', donne. 
 
Note: if you want to split the paragraph not by Line, but by sentence(ended by .!? or ." !" ?"), you can change "replace with pattern" in step 2 to: 

Screenshot 1:  Replace_Window


Similar Examples:
How to exchange the 1st and 2nd lines in each paragraph? (72%)
How to randomly generate some of the permutation of paragraphs? (66%)
How to randomly deletes x number of lines from text files? (62%)
How to randomly select 2~5 lines and append a string at end? (59%)
How to add some text before each paragraph automatically? (59%)
How to correct typos in a paragraph? (59%)
How to sort paragraphs base on the second word in each paragraph? (58%)
How to randomly replace one line from line 7 to line 10 with the same numbers of -? (57%)

Check Demo of Text file parser
Keywords:
blocks  randomly select  block  sentence  more than  randomly  different number  separate  blank line  paragraph  blocks of text  one blank line between each line of text  split text file by number of lines  blank lines split  split text file by number of line  split text file number of lines  split blank  contains number