Take the 2-minute tour ×

I have about 1,200 rows and I am trying to put them into columns after every twenty rows. How would I do this with out manually copying and pasting a hundred times? Also, I would like to add the values of each resulting column and take the average. Thanks for your help!

share|improve this question

2 Answers 2

There probably is a way to do this in LibreOffice, but I think it'd be simpler to use a scripting language for this, e.g. Perl. Save the sheet to a text file (e.g. input.txt) and run the following command:

 perl -ne '
   BEGIN{ $i=0 }
   if (defined $arr[$i]) {
     $arr[$i] .= ",".$_;
   } else {
     $arr[$i] = $_;
   $i = ($i + 1) % 20;
   END { print join "\n", @arr }
 ' input.txt > output.csv

Import output.csv in LibreOffice.

share|improve this answer
This was a good idea. I used PHP and averaged every twenty numbers. I found out the csv syntax to make a new column. While commas divide each value into a new cell, a carriage return divides the next values into a new column. I would still like to know how to directly do this in libre office –  Will Oct 12 '12 at 21:56

You can probably do this with the " =OFFSET() " function in Excel, or since you're using Libre Office it has something similar called " =INDEX() " I think.

share|improve this answer
I would need something more specific. Thanks –  Will Oct 12 '12 at 21:47

Your Answer


