Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1156.Text file parser -- How to remove lines that contain some words base on percentages?

User: Aaron -- 2013-12-09          << 1155  1157 >>
Hits: 1101
Type: Text file parser   
Search all Text file parser examples
Description:
Variation of script 560. How to remove all the lines that do not contain any of words in a list based on percentages?
Input Sample:
word_list.txt

word1|word2|word3

Keep only 50% of lines with word1 and all occurrences of word2 and word3


input.txt

.....word1......
...............
....word1........
..word2...........
.................
............
..word3........... 
Output Sample:
Output Sample: (50% of lines with word1 remain)


.....word1......
....word2........
..word3........... 
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 with pattern' to:

* click 'advanced' tab
set 'run following for each matched unit' to:

3. click 'replace', done.

Note: you can adjust 0.5 to other values.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to remove all lines that contain one or more words in a list? (74%)
How to remove all the lines that do not contain any of words in a list? (68%)
How to remove lines containing specified words in a text file? (67%)
How to remove all lines that contain some specific strings in a text file? (67%)
How to remove all lines that contains more than one word? (66%)
How to delete all lines that contain only a word and a blank? (65%)
How to extract all lines that contain specific words in a file? (64%)
How to extract all lines that contain words in a list? (64%)

Check Demo of Text file parser
Keywords:
adjust  ray  array  how to remove lines that contain  based on  grep  unique  var  remove all the lines  script  split text file based on pattern  words that replace join  join sort split match n  sort all words in a text file  lines contain words  sort words text file  advanced text file parser  sort all lines