Created
June 6, 2014 00:29
-
-
Save jeroenjanssens/af091bc6e1dbb8a656c7 to your computer and use it in GitHub Desktop.
Remove header without streaming entire file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# The trick is to overwrite the file with spaces till the first newline. | |
# Only works if the program that reads it ignores empty lines. | |
import sys | |
filename = sys.argv[1] | |
f = open(filename, "r+b") | |
n = 0 | |
while f.read(1) != "\n": | |
n += 1 | |
f.seek(0) | |
f.write(" " * n) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment