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?

tshepang
12.5k25 gold badges98 silver badges140 bronze badges
asked Jan 30, 2013 at 4:28

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

answered Jan 30, 2013 at 4:32
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.