[Tutor] converting xls to csv

Sander Sweers sander.sweers at gmail.com
Sun Jun 7 16:04:18 CEST 2009


On Sun, 2009-06-07 at 00:54 +0200, Sander Sweers wrote:
> 2009/6/6 Nick Burgess <burgess.nick at gmail.com>:
> > Is it posible to take
> > the regex compile from user input?  To make it take an argument,  like
> >
> >> csvSearch.py 10.192.55
> 
> You can use raw_input() see [1] for the docs
>   user_input = raw_input('Please provide input')

Ugh, I really should not write e-mail 2 in the morning.... :(

What you are looking for is command line options. Command line options
are stored in sys.argv, see [1].

import sys
opts = sys.argv[1:] #sys.argv[0] is filename
print opts

You will need to validate the input so your module does not raise an
exception.

If you are planning to do more advanced commandline options you should
look at the optparse module [2].

Greets
Sander

[1] http://docs.python.org/library/sys.html#sys.argv
[2] http://docs.python.org/library/optparse.html



More information about the Tutor mailing list