Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1159.Text file parser -- How to extract all data followed by specified words from many files?

User: Andy -- 2013-12-15          << 1158  1160 >>
Hits: 3935
Type: Text file parser   
Search all Text file parser examples
Description:
How to extract all data followed by specified words from many files? 
For example, extract format of ##.##-##.## after each Crude Soybean, or Soybean Meal R, Soybean Meal T, and so on. 
For each file, generate a new line with part of filename like (20131212) as first word.
Input Sample:
File1:MS_GR11720131212.txt 
... 
Crude Soybean Oil       37.74- 38.49      dn 0.41          -225F to-150 F unch 
 
46.5% Soybean Meal R   445.10- 455.10     dn 8.8           +15 F to +25 F unch 
 
46.5% Soybean Meal T   445.10- 460.10     dn 8.8           +15 F to +30 F unch 
 
Soybean Hulls-bulk     170.00- 190.00     unch 
 
Soybean Hulls-pellets  170.00- 195.00     dn 1000-unch 
 
File2:... 
File3:... 
  
Output Sample:
20131212 37.74 38.49 445.10 455.10 445.10 460.10 170.00 190.00 170.00 195.00 12.6975 13.0175 20.25 18.25  
lines for file2... 
lines for file3...
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. open "Tools->Batch Runner" menu 
2. drag multiple files from "Windows File Browser" to "Batch Runner" window 
3. click "Fast Replace" button 
(1)click "add" to add 1st rule: 
* set "search" to:  
* set "replace" to:  
* click ok 
(2)click "add" again to add 2nd rule: 
* set "search" to:  
* set "replace" to:  
* click ok 
(3)repeat step 3(2), until all the rules are added, note that special letters(like $ % .)should be escaped(like \$ \% \.), if the format is not ##.##-##.##, you should change accordingly(follow regular exp syntax). 
(4)click "add" again to add next rule: 
* set "search" to:  
* set "replace" to:  
* click ok 
4. check option of "Reg exp", "Cross Line", and "Extract" 
5. click "start", and select "output to single file", done. 
 
Note: don't forget to check "Extract".

Screenshot 1:  Fast_Replace_Window


Similar Examples:
How to extract lines containg specified words from many files? (78%)
How to extract multiple lines in specified order from many text files? (74%)
How to extract all lines by specified words in group? (71%)
How to extract all lines that contain specific words in a file? (70%)
How to count the occurrance of some specified words in many files? (70%)
How to extract all specified links from a html file? (69%)
How to extract the certain line that follow the specified line? (68%)
How to extract all data like ##.##-##.## from many files? (67%)

Check Demo of Text file parser
Keywords:
312  cap  1st  special  2nd  syntax  tax  repeat  specified words  letters  file all words with 5 letters  extract 1st line  add letters to multiple files  first 4 letters  extract 2nd line  first letters  extract words that start with  add first line to start of each line