Nik
2008-Aug-30 00:40 UTC
split a long string of output data separated by space and occasional timestamp.
Hello all! I have this image program that outputs data which looks like this (w/o the quotes): "00:01:08 8384.12 8373.34 8334.84 8313.32 00:02:37 8284.22 8237.37 8199.34 00:03:13 8178.10 8138.12 8101.23..." So in English "timestamp number number number number timestamp number number number timestamp number number..." And the time stamps do not come regularly (semi-regularly, about every 3 seconds) and this is one long line of data like this. So if I wanted to give each of those numbers an averaged time stamp (by subtracting two neighboring timestamp, and divide by the number of numbers in between these two timestamps and give the first number the first timestamp, the second number that first time stamp plus the averaged value, then the next twice the averaged value, then the next thrice the averaged value, and so on. Then I have [timestamp, number] pairs. how can I do this? Thank You! Nik --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joe K
2008-Aug-30 02:38 UTC
Re: split a long string of output data separated by space and occasional timestamp.
Split the string on spaces, then iterate through the array and use slice! to remove successive sequences when the element includes a colon. On Fri, Aug 29, 2008 at 8:40 PM, Nik <NiKSOsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello all! > > I have this image program that outputs data which looks like this (w/o > the quotes): > "00:01:08 8384.12 8373.34 8334.84 8313.32 00:02:37 8284.22 8237.37 > 8199.34 00:03:13 8178.10 8138.12 8101.23..." > > So in English "timestamp number number number number timestamp number > number number timestamp number number..." > > And the time stamps do not come regularly (semi-regularly, about every > 3 seconds) and this is one long line of data like this. > > So if I wanted to give each of those numbers an averaged time stamp > (by subtracting two neighboring timestamp, and divide by the number of > numbers in between these two timestamps and give the first number the > first timestamp, the second number that first time stamp plus the > averaged value, then the next twice the averaged value, then the next > thrice the averaged value, and so on. > > Then I have [timestamp, number] pairs. > > how can I do this? > > Thank You! > Nik > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---