[Tutor] for k,v in d: ValueError: too many values to unpack

2007-05-21 Thread John Washakie
I have a Dictionary, that is made up of keys which are email addresses, and values which are a list of firstname, lastnamet, address, etc... If I run the following: #! /bin/python import csv last = {} rdr = csv.DictReader(file("reg-data.csv")) for row in rdr: #print row last[row

Re: [Tutor] Running and passing variables to/from Fortran

2007-05-12 Thread John Washakie
WAY too large a project I'm afraid. Yes, that would be the one which would make me an 'expert' in Python ;) Too bad there's just no time right now... On 5/10/07, Bob Gailer <[EMAIL PROTECTED]> wrote: > John Washakie wrote: > > I have access to the source code

Re: [Tutor] Alright... I'm new...

2007-05-09 Thread John Washakie
> > I want to create a fully functional program that actually does something > USEFUL. And just what would that be? Ask yourself that.. then perhaps folks on the list could guide you in the right direction... -j ___ Tutor maillist - Tutor@python.org h

Re: [Tutor] Running and passing variables to/from Fortran

2007-05-09 Thread John Washakie
I have access to the source code. And I probably could pass the data to stdout, so maybe .popen would work! I'll have a look... thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Running and passing variables to/from Fortran

2007-05-06 Thread John Washakie
I have a FORTRAN program which reads in unformatted sparse matrix data. Rather than rewriting the code in Python, I was hoping there is a way to call the Fortran program, passing filename variables TO Fortran, and returning the data (which is an array) back to my .py code for use there. Is there a

Re: [Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread John Washakie
And of course, thanks all! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread John Washakie
It aint pretty! And if I had just walked away, it probably would've taken half the time in the morning, but here's what I've come up with (any suggestions for improvements, or course are welcome): for d in data: w = len(d) if d[0] <= tinit+60: d = column_stack(d)

Re: [Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread John Washakie
Ug, It still doesn't make sense due to the sum/cnt where cnt is just an int, and sum is a 1-dimensional array! I'm missing something here about working with numpy arrays... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/

Re: [Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread John Washakie
Thanks for the feedback, The average was a little bit goofed up. Here's what I have now: for d in data: if d[0] <= tinit+60: d = column_stack(d) cnt=cnt+1 sum = sum+d else: avg = sum/cnt if init==0: newData = av

Re: [Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread John Washakie
Oops, I meant it crashes at line 7.. > > 1) tinit = data[0][0] > 2)for d in data: > 3)if d[0] <= tinit+60: > 4)sum = sum+d > 5)else: > 6)avg = sum/len(sum) > 7)newData = append([newData],[avg],axis=0) > 8)tinit = d[0] > >

[Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread John Washakie
Hello, I'm trying to calculate an average for columns in my array(data), there's a catch though, I want to create a new array of shorter length (NOTE: this crashes at line 8): 1) tinit = data[0][0] 2)for d in data: 3)if d[0] <= tinit+60: 4)sum = sum+d 5)else: 6)

Re: [Tutor] Running a program

2007-05-01 Thread John Washakie
Jessica, Assuming you have python installed on your system (Windows?, *nix?), then all you have to do is double click the .py file and it will run. If you want, you can run it from the command line: C:\> python yourfile.py On 5/1/07, Jessica Brink <[EMAIL PROTECTED]> wrote: > > > I know thi

Re: [Tutor] if in an iteration, quick Q!!

2007-05-01 Thread John Washakie
Thanks > > Depending on what an 'empty' element is you may have to refine that. > I also noted, if I used: tmp = data[6].strip().split() rather than: tmp = data[6].strip().split(' ') I eliminated the 'empty' elements... ___ Tutor maillist - Tuto

[Tutor] if in an iteration, quick Q!!

2007-05-01 Thread John Washakie
I can't recall how to do this: I want: a = [int(x) for x in tmp] but, my tmp has some empty elements, so it fails... Therefore I want to be able to say: a = [int(x) for x in tmp IF x in tmp] I know there's a way! Ive seen it before, but now cannot find it! 'if' is a pretty generic thing to se

[Tutor] listing files in an html directory

2007-04-29 Thread John Washakie
Hello all, I'm trying to write a program which will take a path, look in it for all files matching a certain pattern, then create javascript player to play them. A key part of the code at this point is: searchPath = imageRoot + '*' + imgExt avail = glob.glob(searchPath) #will glob work over http

[Tutor] a way to glob over http?

2007-04-26 Thread John Washakie
Hello all, I'm writing a program which take input about a path. The path may be http or absolute or local. Once I have the path, I want to search the directory for images (type also defined by user), then get a count on the number of images in order to build the rest of my program: searchPath = i

Re: [Tutor] best search/replace method?

2007-04-25 Thread John Washakie
Excellent. Thanks Luke, that seems to be working On 4/25/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > John Washakie wrote: > > Tested. Failed... > > > > I thought it would be something like that, but that doesn't work.. > > perhaps because '

Re: [Tutor] best search/replace method?

2007-04-25 Thread John Washakie
TECTED]> wrote: > On 4/25/07, John Washakie <[EMAIL PROTECTED]> wrote: > > > cat raw.html | > > sed 's/ImagePathReplaceMe/NewPathToImage/g' | > > sed 's/TitleReplaceMe/NewTitle/g' > new.html > > One line's sufficient: >

[Tutor] best search/replace method?

2007-04-25 Thread John Washakie
Folks, I'm writing a program which will read in an html file, and then replace certain elements, such as the title, and various paths defined for images. I can make a 'source' file with ImagePathReplaceMe and TitleReplaceMe text in it, then search for that and replace it. With sed my script would