Advertisement
cd62131

binary i/o

Jun 3rd, 2019
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 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. data_size = int(sys.argv[2])
  6. if record_size < data_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(record_size)
  10.         while data:
  11.             w.write(data[:data_size])
  12.             data = f.read(record_size)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement