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
Hits: 58
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" 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

Similar Examples:
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 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%)
How to shuffle all the lines in a text file? (62%)
How to extract/parse all http addresses from text/html file? (61%)
How to extract all IP address from a text file? (61%)
How to merge two or more csv files with different columns into one file? (60%)

Check Demo of Text file parser