Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

334.Text merge -- How to merge two text file base on the value of first column and do sort?

User: editor -- 2009-05-20          << 333  335 >>
Hits: 2944
Type: Text merge   
Search all Text merge examples
Description:
I want to sort two data sets of fundamental stocks values, two spreadsheets of data, each with two columns of data imputed from two txt files. The data are not sequential and the sort desired produces a data txt output file for a third
spreadsheet, which aligns the data sets.
Input Sample:
SHEET 1 (imput as txt file)
A    x                     
B    x                     
C    x                     
D    x                     
E    x                     
F    x                     
G    x                     

Sheet 2 (imput as txt file)
A    x
B    x
D    x
F    x
H    x
J    x
C    x                      
Output Sample:
SHEET 3
A  x     A  x
B  x     B  x
C  x     C  x
D  x     D  x
E  x      .....
F  x     F  x
G  x     ....
.....     H  x
.....     .....
.....     J  x
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
The solution is to merge the 2nd column of two files base on the value of 1st column, and do a sort operation at last.
Detailed procedures:

1. join the two txt files into one file, with one blank line between two files:
A    x
B    x
C    x
D    x
E    x
F    x
G    x
<here is one blank line>
A    x
B    x
D    x
F    x
H    x
J    x
C    x

2. ctrl-o open the text file prepared in step 1.
3. ctrl-h open 'replace' dialog
* set 'Replace Unit' to 'Line'
* set 'Replace Scope' to 'Paragraph'
** click "Advanced" page
* set "Run following at the beginning of replace" to:

* set "Run following for each matched unit" to:

* set "Insert End Text" to:

4. Click "Replace", done! 
Download Script:  scripts/334.rst.zip

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to merge other columns' data base on the value of the first column? (70%)
How to merge the data of second column base on value of first column? (69%)
How to merge two or more csv files with different columns into one file? (60%)
How to search and replace text base on csv file column 1 and 2? (59%)
How to merge adjacent lines having same value in column one in CSV files? (59%)
How to merge consecutive lines that have the same first column? (58%)
How to remove lines from file B.csv with first column come from file A.csv? (57%)
How to delete the 4th column from text files with 8 columns? (57%)

Check Demo of Text merge
Keywords:
align  spreadsheet  sequential  third  merge two text file  merge two  1st  2nd  two files  toc  merge each line of two files into one line  join two files for each line  merge base column  join files columns  one blank line between each line of text  sequential merge  merge base  merge two line into one