Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1271.Text data calculation -- How to merge text by first column and calculate average for rest columns?

User: shanfeng -- 2014-12-09          << 1270  1272 >>
Hits: 2901
Type: Text data calculation   
Search all Text data calculation examples
How to merge and average unique lines with same character in the first column  
found in from different files?
Input Sample:
File A: 
59750 1.2 1.4 1.8 
59752 1.2 1.6 1.4 
59753 1.2 1.8 1.2 
File B: 
59750 1.2 1.6 1.8 
59751 1.2 1.4 1.6 
59752 1.2 1.6 1.8 
Output Sample:
59750 1.2 1.5 1.8 
59751 1.2 1.4 1.6 
59752 1.2 1.6 1.6 
59753 1.2 1.8 1.2
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
For multiple file, you should join them into a single file at first, then you can do following steps: 
1. ctrl-o open the file(already joined together) 
2. ctrl-h open 'replace' dialogue 
* set 'replace unit' to 'Line' 
click 'advanced' tab 
* set 'insert begin text' to: 
* set 'run following at the beginning of replace' to: 
* set 'run following for each matched unit' to: 
3. click 'replace', done.

Screenshot 1:  Replace_Window

Screenshot 2:  Replace_Advanced_Window

Similar Examples:
How to calculate the average of numbers of one column? (61%)
How to extract the 7th column from text files with 8 columns? (61%)
How to multiply the first column with the rest of columns in one file? (61%)
How to calculate the average of the numbers in the same column? (59%)
How to delete the 4th column from text files with 8 columns? (58%)
How to extract column X from csv file where X is decided by column A? (58%)
How to remove/delete first column for multiple files? (57%)
How to reverse the order of the first column in text file? (56%)

Check Demo of Text data calculation
calculate average  keys  average  rage  unique lines  grep  dictionary  diction  together  found  insert different text into multiple files  join lines different files  merge single column multiple files  merge text files by columns  join lines multiple files  insert lines at beginning of file multiple files  insert a character  insert character