Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

606.Text file splitter -- How to split a text file to different files according to first word in each line?

User: editor -- 2010-09-07          << 605  607 >>
Hits: 3720
Type: Text file splitter   
Search all Text file splitter examples
Description:
How to split a text file to different files according to first word in each line? 
Need to split a base file with format of "filename-linexxx" in each line, and write each "linexxx" into corresponding "filename".
Input Sample:
The source file list.txt contain following lines: 
d:\temp\a.txt-1111 
d:\temp\b.txt-2222 
d:\temp\a.txt-3333 
d:\temp\a.txt-4444 
d:\temp\b.txt-5555
Output Sample:
The target files are: 
d:\temp\a.txt 
1111 
3333 
4444 
d:\temp\b.txt 
2222 
5555
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open list.txt 
2. ctrl-h open replace window 
* set 'replace unit' to 'line' 
* in 'search for pattern', enter: 
 
* click "advanced" tab  
fill "run following for each matched unit" entry like: 
 
3. click 'Replace' button, done. 
 
Note: for multiple files, you need to click "Batch..." button
Download Script:  scripts/606.rst.zip

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to split a text file to different files according to first word in each line? (100%)
How to split a text file according to first word in each line? (86%)
How to split a file into many files according to first letter of each line? (81%)
How to process text files, only keep the first word of each line? (66%)
How to batch split file delimitered by first dash in each line? (65%)
How to split a text file according to specified tags? (63%)
How to split a file into two parts according to the content of line? (63%)
How to limit a text file to less than 40 chars each line? (63%)

Check Demo of Text file splitter
Keywords:
split a text file to different files according to first word in each line  write  var  xxx  splitter  text file splitter  acc  first word  different files  different file  replace first word of filename  split text file according to word  advanced text file splitter  advanced text splitter  split according to first  split text file according to  file split according to text  split file according to line