Created
April 16, 2009 14:37
-
-
Save sanity/96439 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
#!/usr/bin/python | |
import sys,random | |
if (len(sys.argv) != 5): | |
print "Args: every input train test" | |
sys.exit(-1) | |
selectevery = int(sys.argv[1]) | |
inputfile = open(sys.argv[2], 'r') | |
trainfile = open(sys.argv[3], 'w') | |
testfile = open(sys.argv[4], 'w') | |
for line in inputfile: | |
if (line != "\n"): | |
if (random.randint(1,selectevery) == 1): | |
testfile.write(line) | |
else: | |
trainfile.write(line) | |
inputfile.close() | |
trainfile.close() | |
testfile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment