# Split a long string of output data separated by space and occasional timestamp

**URL:** <https://www.ruby-forum.com/t/split-a-long-string-of-output-data-separated-by-space-and-occasional-timestamp/147272>\
**Category:** Rails\
**Created:** [August 30, 2008, 2:41am UTC](https://www.ruby-forum.com/t/split-a-long-string-of-output-data-separated-by-space-and-occasional-timestamp/147272 "2008-08-30T02:41:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/6de8d8/32.png) [@nik](https://www.ruby-forum.com/u/nik)\
**Post date:** [August 30, 2008, 2:41am UTC](https://www.ruby-forum.com/t/split-a-long-string-of-output-data-separated-by-space-and-occasional-timestamp/147272/1 "2008-08-30T02:41:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/6de8d8/32.png) [@nik](https://www.ruby-forum.com/u/nik)\
**Post date:** [August 30, 2008, 4:39am UTC](https://www.ruby-forum.com/t/split-a-long-string-of-output-data-separated-by-space-and-occasional-timestamp/147272/2 "2008-08-30T04:39:25Z")

</div>

Split the string on spaces, then iterate through the array and use  
slice! to  
remove successive sequences when the element includes a colon.
