Skip to content

Instantly share code, notes, and snippets.

@gartenfeld
Last active December 12, 2015 02:39
Show Gist options
  • Save gartenfeld/4700637 to your computer and use it in GitHub Desktop.
Save gartenfeld/4700637 to your computer and use it in GitHub Desktop.
Processing multiple files.
def main():
# Command-line parsing supports filename*.txt
# Make a list of command line arguments, omitting the [0] element which is the script itself.
args = sys.argv[1:]
if not args:
print 'Some message.'
sys.exit(1)
for filename in args:
results = do_something(filename)
# Write output file
outf = open('output'+'name', 'w')
outf.write(results + '\n')
outf.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment