adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread brian cleere
I know the problem is with the for loop but don't know how to fix. Any help with explanation would be appreciated. #!/bin/env python import csv import sys if len(sys.argv) 3: print('Please specify a filename and column number: {} [csvfile] [column]'.format(sys.argv[0])) sys.exit(1)

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Tim Chase
On 2013-12-11 11:10, brian cleere wrote: filename = sys.argv[1] column = int(sys.argv[2]) for line in filename() , column (): elements = line.strip().split(',') values.append(int(elements[col])) 1) you need to open the file 2) you need to make use of the csv module on that file

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Chris Angelico
On Thu, Dec 12, 2013 at 6:10 AM, brian cleere briancle...@gmail.com wrote: I know the problem is with the for loop but don't know how to fix. Any help with explanation would be appreciated. Your problem is akin to debugging an empty file :) It's not so much a matter of fixing what's not

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Mark Lawrence
On 11/12/2013 19:10, brian cleere wrote: I know the problem is with the for loop but don't know how to fix. Any help with explanation would be appreciated. #!/bin/env python import csv You never use the csv module. import sys if len(sys.argv) 3: print('Please specify a filename and

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Mark Lawrence
On 11/12/2013 19:22, Chris Angelico wrote: On Thu, Dec 12, 2013 at 6:10 AM, brian cleere briancle...@gmail.com wrote: I know the problem is with the for loop but don't know how to fix. Any help with explanation would be appreciated. Your problem is akin to debugging an empty file :) It's not

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Chris Angelico
On Thu, Dec 12, 2013 at 6:41 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: Square brackets in a usage description often mean optional. You may want to be careful of that. There's no really good solution though. There is, https://pypi.python.org/pypi/docopt/0.6.1 :) That appears to use x

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Mark Lawrence
On 11/12/2013 19:46, Chris Angelico wrote: On Thu, Dec 12, 2013 at 6:41 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: Square brackets in a usage description often mean optional. You may want to be careful of that. There's no really good solution though. There is,

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Chris Angelico
On Thu, Dec 12, 2013 at 7:00 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: I use the alternative X for a mandatory argument X. Also common, but how do you specify a keyword, then? Say you have a command with subcommands: $0 foo x y Move the foo to (x,y) $0 bar x y z Go to bar X, order a Y,

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Tim Chase
On 2013-12-12 07:03, Chris Angelico wrote: Also common, but how do you specify a keyword, then? Say you have a command with subcommands: $0 foo x y Move the foo to (x,y) $0 bar x y z Go to bar X, order a Y, and Z it [eg 'compress', 'gzip', 'drink'] How do you show that x/y/z are

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Mark Lawrence
On 11/12/2013 20:03, Chris Angelico wrote: On Thu, Dec 12, 2013 at 7:00 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: I use the alternative X for a mandatory argument X. Also common, but how do you specify a keyword, then? Say you have a command with subcommands: $0 foo x y Move the foo

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread Christopher Welborn
On 12/11/2013 01:41 PM, Mark Lawrence wrote: On 11/12/2013 19:22, Chris Angelico wrote: There is, https://pypi.python.org/pypi/docopt/0.6.1 :) +1 for docopt. It makes everything very clear. Just type out your usage string, and then run docopt(usage_str) on it to get a dict of your args.

Re: adding values from a csv column and getting the mean. beginner help

2013-12-11 Thread M.F.
On 12/12/2013 03:10 AM, brian cleere wrote: I know the problem is with the for loop but don't know how to fix. Any help with explanation would be appreciated. #!/bin/env python import csv import sys if len(sys.argv) 3: print('Please specify a filename and column number: {} [csvfile]