Created
February 25, 2015 19:59
-
-
Save rbarzic/1f3a74f2558676fb5683 to your computer and use it in GitHub Desktop.
Reading a file line by line in python (with argument)
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 | |
import argparse | |
def get_args(): | |
""" | |
Get command line arguments | |
""" | |
parser = argparse.ArgumentParser(description=""" | |
Put description of application here | |
""") | |
parser.add_argument('--infile', action='store', dest='infile', | |
help='file to be read') | |
parser.add_argument('--version', action='version', version='%(prog)s 0.1') | |
return parser.parse_args() | |
if __name__ == '__main__': | |
args = get_args() | |
with open(args.infile) as f: | |
for line in f: | |
print ">" + line.strip('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment