Reduce Rows or Columns from Worksheet

When dealing with large dataset, you may want to reduce data before performing analysis or graphing. There are multiple ways to reduce data in Origin. This post will demonstrate how to reduce rows and columns from GUI and the corresponding LabTalk scripts.

Download Reduce_Rows_Columns.zip to follow the procedures below. Results are kept in Results folder of the opj file.

Reduce Rows

Go to Folder1 and workbook Nitrite. The data is collected in every 0.01 sec.

DOC-2350_1

First let’s reduce data to around every second. Highlight Col(A) and Col(B), and choose Worksheet: Reduce Rows… menu. Set the settings as following.

DOC-2350_2

After clicking OK, the reduced data are added to new columns.

DOC-2350_3

Right click on Sparklines row in workbook and choose Add or Update Sparklines. Click OK to add sparklines of each column. Comparing column B and D, you can see many peaks are lost in the reduced data.

DOC-2350_4

To preserve peak shapes, we need to keep more data. Just left click the green lock DOC-2350_5on column C and choose Change Parameters context menu to open the dialog again. Change Delete Rows to 9 and click OK. Now the data is reduced to every 0.1 second. The sparklines of column C and D are updated and show a better data reduction.

DOC-2350_5

Reduce Rows in Origin is based on X-Function wreducerows. To see the script behind it, left click the green lock
DOC-2350_5on column C and choose Generate Script context menu. The script is dumped into Script Window. You can use the script in the future to do such data reduction.

DOC-2350_12         DOC-2350_8

 

 

 

 

 

 

 

There are other Reduce Methods, e.g. Reduce N rows with merged values: mean, min, max, etc.

 DOC-2350_6

Reduce Columns

Similarly we have Reduce Columns dialog to reduce data column wise. Look at Sensor workbook in Folder1. There are many 3 XY pairs of data for each sensor. All X columns are the same.

DOC-2350_9

If you want to remove all duplicated X columns and get the average Y values for each sensor,you need to use the Reduce Columns dialog twice.

First, delete every other column starting from the 3rd column to remove all duplicated X columns. See the images below.

DOC-2350_10

Then with the new worksheet active, open the Reduce Columns dialog again to merge every 3 Y columns by averaging. See the images below.

DOC-2350_11

You can also run following scripts to run reduce columns twice without opening dialog.

 

Note:

From the dialog, you can click the arrow next to Dialog Theme anytime to generate script based on your current settings .

DOC-2350_7

 

Leave a Reply