Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

335.Text data calculation -- How to group txt data according to user-defined number of lines, and calculate a sub-total for each sub-group?

User: editor -- 2009-05-25          << 334  336 >>
Hits: 530
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


Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in /home/mindp9/public_html/services/conv_view.php on line 212

Similar Examples:
How to join groups of lines together in a text file according to user defined  rule? (49%)
How to duplicate column A by the number of times in column B in csv file? (47%)
How to enclose all the odd number of lines with a pair of tags? (46%)
How to split a single line into many lines, keep two words for each line? (46%)
How to replace a word/string with increasing sequence number in a text file? (45%)
How to count and sort the occurrence of different numbers in a text file? (44%)
How to split a file by specified number of lines like 10,20,30,20,20,20 ...? (44%)
How to count the number of ip addresses from each country? (43%)

Check Demo of Text data calculation
Keywords:
ddd  delimiters  paragraphs  week  minimum  mad  paragraph delimiter  month  groups  combine  combine lines  group lines  calculation of all number  combine txt  fixed number  calculate lines  insert data  replace with a group