Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1366.Count and statistics -- How to count the number of specified part in each line?

User: Verotiana -- 2016-05-23          << 1365  1367 >>
Hits: 814
Type: Count and statistics   
Search all Count and statistics examples
Count the number of times a line with the same first column (sequence
number) and same last two columns is repeated.
Output the first column, the last two columns and the number of times it

If possible at the end, count the number of times the same last two column
pattern has appeared with distinct sequence numbers, and the average times
it has appeared with each sequence number.

This can be split in two steps if it can't work with one step.
Thank you.
Input Sample:
 1430 F C      
 1430 F C B      
 1430 F C B R     
 1357 G F      
 1357 G F      
 1357 G F      
 1357 G F      
 1357 G F C      
 1357 G F C B     
 1357 G F C B R     
 1431 F C      
 1431 F C B      
 1358 G F      
 1432 F C      
 1432 F C B      
 1432 F C B R     
 1359 G F      
 1359 G F   
Output Sample:
1430 F C 1
1430 C B 1
1430 B R 1
1357 G F 4
1357 F C 1
1357 C B 1
1357 B R 1
1431 F C 1
1431 C B 1
1358 G F 1
1432 F C 1
1432 C B 1
1432 B R 1
1359 G F 2

F C 4/1
C B 4/1
B R 3/1
G F 3/2.333
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 'Line'
click 'advanced' tab:
* set 'run following at the begin' to:

* set 'run following for each ..':

* set 'insert end text':

3. click 'replace', the first part is done.
4. ctrl-h open 'replace' dialogue again
* set 'replace unit' to 'Line'
* set 'replace with pattern':

click 'advanced' tab:
* set 'run following at the begin':

* set 'run following for each ..':

* set 'insert end text':

5. click 'replace'

Screenshot 1:  Replace_Window

Screenshot 2:  Replace_Advanced_Window

Screenshot 3:  Replace_Window

Screenshot 4:  Replace_Advanced_Window

Similar Examples:
How to sort the text by the number of specific word in each line? (75%)
How to count the occurrance of specific pattern in each line of text file? (70%)
How to count the number of consecutive identical lines? (68%)
How to batch replace files with specified format in each line? (68%)
How to count the number of lines under each specified pattern? (67%)
How to add a space at the specific location of each line? (67%)
How to multiply numeric values after specified symbol in each line? (66%)
How to count the number of consecutive lines with specified pattern? (66%)

Check Demo of Count and statistics
repeated  average  rage  grep  total  repeat  times  insert end text  insert end  sequence number  last part  replace line with two numbers  replace a sequence of numbers in text file  count columns  replace text with specified times  average the columns in a text file  insert a number column  sequence number of each line in a text file