User: Aaron -- 2013-07-19 << 1108 1110 >> |
Hits: 3391 |
Type: Text file parser |
Search all Text file parser examples |
Description: |
I would like a script that extracts multiple lines from multiple files based on a keyword or key phrase list. I would also save the output files by keyword name. For example, extract all lines from all files with keyword "car" from keywords list into an output file called "car." Same for "travel" "home". |
Input Sample: |
Input: file1.txt ......car ......... ....travel.... home... ....... etc. file2.txt ....... ....... home... ....... etc. file3.txt travel... .... travel to Europe... ...... ...... etc. keyword or keyphrase file: home car travel to Europe travel etc. |
Output Sample: |
Output files: 1. car.txt: ......car 2. home.txt home... home... 3. travel.txt ....travel.... travel... travel to Europe... 4. travel to Europe.txt travel to Europe... |
Answer: |
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps. |
0. to avoid duplicate content, clear all files in destination folder, such as d:\test\ 1. ctrl-h open 'replace' dialogue * set "replace unit" to 'Line' * set "replace with pattern" to: * click 'advanced' tab, set "run following at the beginning of replace" to: * set "run following for each matched unit" to: 2. click "Batch..." button 3. drag multiple files to "batch runner" window 4. check "set output filename" option, and change the following entry to blank(default is "${FILENAME}"), this step is to avoid original file being overwritten. 5. click "batch replace", all required files will be generated at d:\test\ folder. |
Screenshot 1: Replace_Window |
Screenshot 2: Replace_Advanced_Window |