I have a huge set of data in Excel file sheet 1. The number of columns is fixed (6) but there are lots of rows.
For every 3 rows, I need to pick out the minimum value of 2nd column and save the whole row into Excel file or sheet 2, how am I going to write the script?
item.xls (sheet 1):
0.3 0.5 0.1 0.8 0.4 0.6
0.2 0.4 0.9 0.1 0.9 0.4
0.2 0.3 0.1 0.01 0.2 0.5
0.3 0.5 0.1 0.8 0.01 0.2
0.2 0.2 0.9 0.1 0.2 0.4
0.2 0.3 0.1 0.01 0.3 0.5
.......
In the first 3 rows, the minimum value of 2nd column is 0.3, then write the whole row into sheet 2 of the Excel file.
Then the next 3 rows, the minimum value of 2nd column is 0.2, then write the whole row into sheet 2 of the Excel file.
The result I would like to get is:
item.xls (sheet2):
0.2 0.3 0.1 0.01 % 1st 3 rows, the minimum value is 0.3 in 2nd column
0.2 0.2 0.9 0.1 % 2nd set of 3 rows, the minimum value is 0.2 in 2nd column
...
I will show how to extract the relevant rows from the data in a vectorized manner. I will leave the part of reading/writing excel files to you (it should be straightforward):