Dear Jesús Gabriel y Galán and all,

> File.open("../original_data/test_2lines.tsv").each_line do |record|
>   a = record.chomp.split("\t")
>   a.each_slice(2).with_index do |(time,signal), index|
>     File.open("#{index}_debug_split"+".tsv" , "w") do |f|
>       f << "#{time}\t#{signal}\n"
>     end
>   end
> end

This code ran well at 1.9.1 version of ruby. Since I tried at our
server where ruby is this version.

Actually, I need to do this also: make the first line's time value
subtracted by other lines' corresponding time ones.

First line: time_1.1, signal_1.1, time_1.2, signal_1.2... time_1.4096, 
signal_1.4096.
Second line: time_2.1, signal_2.1, time_2.2, signal_2.2... time_2.4096, 
signal_2.4096.
.......

I would like to do,  time_2.1 = time_2.1 - time_1.1 , time_2.2 = 
time_2.2 - time_1.2 ,
...... time_2.4096 = time_2.4096 - time_1.4096.
                             ......
Similar to other lines' time value.

I tried to use a counter to pick up the first line (stupid way, I know) 
than save in an array, and
take other lines time values to subtract this array, but failed. Since 
it seemed
to the enumerator I could not access individual ? But "puts a[index] " 
printed two items
(time and signal) well.  However, i could not print just time or signal 
value.

Thanks a lot for in advance!
Best,
Junhui
-- 
Posted via http://www.ruby-forum.com/.