Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

335.Text data calculation -- How to calculate sub-total for each group with user-defined number of lines?

User: editor -- 2009-05-25          << 334  336 >>
Hits: 3350
Type: Text data calculation   
Search all Text data calculation examples
Description:
I want to combine data rows in groups equal to weeks such that a month is made of four groups or weeks.  The data is stock data and not all months are five day weeks because of holidays closing a market day.  Hence, I would accept dividing each month into 4 groups.  Can Replace Pioneer create four groups and total the columns? 
OPEN is the Average of all data rows 
HIGH is the Maximum value from the data rows 
LOW is the minimum value from the data rows 
VOLUME and CLOSE are the Average value
Input Sample:
01/02/09 00:00 5.08 5.24 5.02 42700.00 5.17 
01/05/09 00:00 5.21 5.26 4.94 58200.00 5.24 
01/06/09 00:00 5.30 5.55 5.11 67400.00 5.45 
01/07/09 ...  
01/08/09 ... 
01/09/09 ... 
01/12/09 ... 
01/13/09 ... 
01/14/09 ... 
01/15/09 ... 
01/16/09 ... 
01/20/09 ... 
01/21/09 ... 
01/22/09 ... 
01/23/09 ... 
01/26/09 ... 
01/27/09 ... 
01/28/09 ... 
01/29/09 00:00 4.50 4.50 4.31 50900.00 4.34 
01/30/09 00:00 4.33 4.71 4.20 74400.00 4.29 
Output Sample:
DATE OPEN HIGH LOW VOLUME CLOSE 
01/02/09 12:00 5.08 5.24 5.02 42700 5.17 
01/05/09 12:00 5.21 5.26 4.94 58200 5.24 
01/06/09 12:00 5.3 5.55 5.11 67400 5.45 
01/07/09 12:00 5.35 5.55 5.21 54600 5.45 
01/08/09 12:00 5.32 5.51 5.32 29100 5.5 
Jan 09 week 1 5.25 5.55 4.94 50400 5.36 
 
01/09/09 12:00 5.46 5.5 5.31 24900 5.37 
01/12/09 12:00 5.21 5.31 5 29500 5.06 
01/13/09 12:00 5.05 5.21 4.98 27000 5 
01/14/09 12:00 5.04 5.32 4.71 67600 4.73 
01/15/09 12:00 4.73 5.17 4.64 52900 5.1 
Jan 09 week 2..
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open txt file 
2. ctrl-h open 'replace' window 
*set "Replace Unit" to "Line" 
*set "Replace Scope" to "Paragraph" 
*set "Replace with Pattern":  
--click 'Setting' page: 
*in 'Paragraph delimiters' frame, Check option of "fixed para lines", and enter "5,5,5,5,5,5,5,4.." at right(week 1 has 5 days, week2 has 5 days ..) 
--click 'Advanced' page: 
*set "Run following for each matched Unit": 
 
*set insert end text: 
 
3.click replace,done!
Download Script:  scripts/335.rst.zip

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to calculate the maximum value of the first n lines? (55%)
How to calculate the sum of the numbers in the same column? (54%)
How to calculate the summary of all numbers in multiple files? (54%)
How to calculate sum value of every column? (53%)
How to calculate the percentage of the number in the column1? (53%)
How to copy one file for many times with pre-defined name in a list? (52%)
How to calculate summary of every column in a text file? (52%)
How to add a specified value to the sequence number in each line? (51%)

Check Demo of Text data calculation
Keywords:
delimiters  paragraph delimiters  week  minimum  user defined  paragraph delimiter  mad  combine  groups  equal  calculate text file rows  create columns  replace with delimiters  replace delimiters  set columns in fixed text file  equal number  combine columns  combine lines