Skip to content
Advertisement

Parsing text file containing unique pattern using Python

How to parse a text file containing this pattern “KEYWORD: Out:” and dump the result into output file using Python?

input.txt

JavaScript

output.txt

JavaScript

Advertisement

Answer

You could use a regex:

JavaScript

If you want to do this line-by-line from a file:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement