2

I am writing a program in Python 3 that will take data from a csv file, make adjustments to it and write the new data to a csv file that will be named by the user.

I'm just trying to understand the command line part. I want it to execute properly in this format.

$ program.py input.csv output.csv

I plan to also make it check that there are 3 total arguments.

My question is where do this filename inputs on the command line go? Are they saved to a default variable? How can I call these filenames within my python program?

1 Answer 1

7

Command line options are stored in sys.argv. You may want to check this:

http://docs.python.org/3/library/sys.html?highlight=argv#sys.argv

Beside, if you need more complex command-line argument parsing and deciding your program logic based on that, you should try argparse

Sign up to request clarification or add additional context in comments.

1 Comment

For calling these filenames, you already have sys.popen, os.system, subprocess modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.