Advertisement
cd62131

binary i/o

May 27th, 2019
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import sys
  3. if len(sys.argv) != 4: sys.ext(1)
  4. record_size = 30000
  5. read_size = int(sys.argv[2])
  6. if record_size < read_size: sys.exit(1)
  7. with open(sys.argv[1], 'rb') as f:
  8.     with open(sys.argv[3], 'wb') as w:
  9.         data = f.read(read_size)
  10.         while data:
  11.             w.write(data.ljust(record_size) + b'\n')
  12.             data = f.read(read_size)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement