Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. # Use the cool variable as a two state latch which will be True
  2. # whenever inside a json block and False outside of it.
  3. cool = False
  4. with open('input.log') as fh:
  5. for line in fh:
  6. if not cool:
  7. if line.startswith('{'): # or some other expression triggering
  8. # the start of a json block
  9. cool = True
  10. print line
  11. else:
  12. print line # This has json
  13. if line.startswith('}'): # end of json
  14. cool = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement