Advertisement
rfmonk

gzip_writelines.py

Jan 30th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. #1/usr/bin/env python
  2.  
  3. # this is from The Python
  4. # Standard Library by example
  5. # ISBN13: 9780321767349
  6.  
  7. # I get: gzcat not found?
  8.  
  9. import gzip
  10. import itertools
  11. import os
  12.  
  13. with gzip.open('example_lines.txt.gz', 'wb') as output:
  14.     output.writelines(
  15.         itertools.repeat('The same line, over and over. \n', 10)
  16.     )
  17.  
  18. os.system('gzcat example_lines.txt.gz')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement