Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

558.Text file parser -- How to parse all the fields in different segment from a text file?

User: editor -- 2010-07-07          << 557  559 >>
Hits: 1742
Type: Text file parser   
Search all Text file parser examples
Description:
How to parse all the fields in different segment from a text file?
Each segment is started with a paragraph without leading '@'. In each segment, join paragragh 8,9,10 ... together, and add a sequence number before each paragraph.
Input Sample:
Acadia National Park

@Bar Harbor, ME U.S.A.


@P.O. Box 177
Eagle Lake Rd
Bar Harbor, ME 04609
U.S.A.

@207-288-3338
877-444-6777 

@Acadia National Park Web Site

@Open Year-Round

@Entry Fee Charged

@Spruces, ...

@other1

@other2

@others 
...

Snake River Birds of Prey National Conservation Area

@Boise, ID U.S.A.

@3948 Development Ave.
Boise, ID 83705
U.S.A.

@208-384-3300 Boise District Office

@Snake River Birds of Prey National Conservation Area W
Output Sample:
1 Acadia National Park 
2 Bar Harbor, ME U.S.A. 
3 P.O. Box 177 Eagle Lake Rd Bar Harbor, ME 04609 U.S.A. 
4 207-288-3338 877-444-6777  
5 Acadia National Park Web Site 
6 Open Year-Round 
7 Entry Fee Charged 
8 Spruces, ... other1 other2 others  ... 
1 Snake River Birds of Prey National Conservation Area 
2 Boise, ID U.S.A. 
3 3948 Development Ave. Boise, ID 83705 U.S.A. 
4 208-384-3300 Boise District Office 
5 Snake River Birds of Prey National Conservation Area
...
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open source text file
2. ctrl-h open 'replace' window
* set 'replace unit' to 'Paragraph'
* set 'Search for pattern' to:

* set 'Replace with pattern' to:

* uncheck option of 'Print Unmatched Unit'

click 'Advanced' page:

set 'Run following for each matched unit' to:


3. click 'Replace', done!
Download Script:  scripts/558.rst.zip

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to extract specified lines in different section of text file? (67%)
How to sort all lines of ip addresses in a text file? (66%)
How to reverse all cases of letters in a text file? (65%)
How to reset all the numbers with format id=NNN in a text file?  (64%)
How to compare and get the difference between numbers of two file? (63%)
How to extract all specified date format from a text file? (63%)
How to put the file list of a directory into a text file? (63%)
How to extract/parse all upper cases Acronyms from a text file? (62%)

Check Demo of Text file parser
Keywords:
paragragh  segme  field  leading  together  pages  without  sequence number  else  paragraph  matched sequence number  sequence number text file  replace text sequence number  replace text to sequence number  before a number  add sequence number  replace with sequence number  replace with number sequence