Last active
August 29, 2015 14:03
-
-
Save pochemuto/752a666fd717cd2a1256 to your computer and use it in GitHub Desktop.
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
# encoding=UTF8 | |
from sys import argv | |
if __name__ == '__main__': | |
fname = "" | |
line_count = 5 | |
if len(argv) >= 3: | |
fname = argv[1] | |
line_count = int(argv[2]) | |
with open(fname) as f: | |
content = f.readlines() | |
messages = len(content) / line_count | |
print "readed %s messages" % (messages) | |
f = open(fname, "w") | |
f.close(); | |
i = 0 | |
while (i < messages): | |
r = raw_input("[%s, %s]" % (i, messages)) | |
if r == "e": | |
with open(fname, "a") as f: | |
f.write("".join(content[i*line_count:])) | |
print "interrupted" | |
break | |
else: | |
with open(fname, "a", 0) as f: | |
for n in range(line_count): | |
f.write(content[i*line_count + n]) | |
i+=1 | |
print "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment