Last active
July 17, 2018 11:07
-
-
Save hdf/e526f1585740f8615e6351437873ccaa 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
import sys | |
if len(sys.argv) < 2: | |
print("""Usage: | |
pick.py data.txt [lines_to_skip = 0] [first_line = 0]""") | |
sys.exit(0) | |
file = sys.argv[1] | |
skip = int(sys.argv[2]) + 1 if len(sys.argv) > 2 else 1 | |
start = int(sys.argv[3]) if len(sys.argv) > 3 else 0 | |
with open(file, "r") as f: | |
lines = f.read().strip().split("\n") | |
for i in range(skip): | |
for line in lines[start::skip]: | |
print(line.strip()) | |
start = start + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment