Re: Building Time Based Bins

2005-03-22 Thread Michael Spencer
MCD wrote: I've mostly been racking my brain with this bit of code: newtm = ((klock + 4) // 5 * 5 ) % 2400 You might want to take another look at the first reply I sent you: it contains a function that does this: def groupkey(data): """Groups times by 5 min resolution. Note this version does

Re: Building Time Based Bins

2005-03-22 Thread MCD
Michael Spencer wrote: > (BTW, there must be more to your code than you have shared for the above line to > execute without raising an exception - where are 'time' and 'a' initially bound? > BTW2, 'time' is the name of a stdlib module, so it's bad practice to use it as > an identifier) Yes there

Re: Building Time Based Bins

2005-03-22 Thread MCD
Ok, thanks Michael, I got it sorted out now. It was just a question of placing the append statement and the new list in the right place. I also added a delete command so the list doesn't become too huge, especially when there's no need to keep it. Here's the corrected code: if bintm == :

Re: Building Time Based Bins

2005-03-21 Thread Michael Spencer
MCD wrote: Hi Michael, thanks for responding. I actually don't use a method to get each bin... That's because you picked the wrong suggestion ;-) No, seriously, you can do it easily with this approach: the bin outputs are nested in the loop. Here's my code: data_file = open('G:\file.txt') DUMM

Re: Building Time Based Bins

2005-03-21 Thread MCD
Hi Michael, thanks for responding. I actually don't use a method to get each bin... the bin outputs are nested in the loop. Here's my code: data_file = open('G:\file.txt') DUMMY = bintm = DUMMY for line in data_file: fields = line.strip().split() if not line: continue ilist = [int

Re: Building Time Based Bins

2005-03-21 Thread Michael Spencer
MCD wrote: Thanks Alessandro... I'll have to try that as well. I have a modified working version of John's code (thanks John!). I'm able to output the bins by 5min intervals, sum one of the fields, and get the high and low of each field. So far I'm really happy with how it works. Thank you to every

Re: Building Time Based Bins

2005-03-21 Thread MCD
Thanks Alessandro... I'll have to try that as well. I have a modified working version of John's code (thanks John!). I'm able to output the bins by 5min intervals, sum one of the fields, and get the high and low of each field. So far I'm really happy with how it works. Thank you to everybody. The

Re: Building Time Based Bins

2005-03-20 Thread alessandro -oggei- ogier
MCD wrote: > This goes on throughout a 12hr. period. I'd like to be able to place > the low and high values of the additional fields in a single line > divided into 5min intervals. So it would look something like this >> > > 1235 22 88 > 1240 31 94 what about a sane list comprehension madness ?

Re: Building Time Based Bins

2005-03-20 Thread MCD
Never mind about the summing... I learned that you can do this: sumhi = 0 sumhi += hi Cool! Thanks again. -- http://mail.python.org/mailman/listinfo/python-list

Re: Building Time Based Bins

2005-03-20 Thread MCD
John Machin wrote: > Are you (extremely) new to computer programming? Is this school > homework? Lol, yes, I am relatively new to programming... and very new to python. I have experience working with loops, if thens, and boolean operations, but I haven't worked with lists or array's as of yet... s

Re: Building Time Based Bins

2005-03-19 Thread John Machin
On 19 Mar 2005 19:01:05 -0800, "MCD" <[EMAIL PROTECTED]> wrote: >Hello, I'm new to python and this group and am trying to build some >bins and was wondering if any of you could kindly help me out. I'm a >bit lost on how to begin. Are you (extremely) new to computer programming? Is this school hom

Re: Building Time Based Bins

2005-03-19 Thread Michael Spencer
MCD wrote: Hello, I'm new to python and this group and am trying to build some bins and was wondering if any of you could kindly help me out. I'm a bit lost on how to begin. I have some text files that have a time filed along with 2 other fields formatted like this >> 1231 23 56 1232 25 79 1234 26

Building Time Based Bins

2005-03-19 Thread MCD
Hello, I'm new to python and this group and am trying to build some bins and was wondering if any of you could kindly help me out. I'm a bit lost on how to begin. I have some text files that have a time filed along with 2 other fields formatted like this >> 1231 23 56 1232 25 79 1234 26 88 1235 2