3.3.2.6 Copy

Copy one dataset into another. Increase the size of the destination dataset as necessary. To determine the number of elements copied with the copy command, use the copy.n object property. The copy command should not be used to move data within the same dataset. Instead, create a duplicate of the worksheet and use that as the source dataset.

Please see the copydata X-Function.

Syntax:

copy  [option] dataset1 dataset2 [dataset3]

Options:

no option;Copy the content of dataset1 into dataset2

Syntax: copy dataset1 dataset2

Copy the content of dataset1 into dataset2.

-a;Append contents of dataset1 to the end of dataset2.

Syntax: copy -a dataset1 dataset2

Append contents of dataset1 to the end of dataset2.

-b;Copy from rowIndex# of dataset1 to dataset2

Syntax: copy -b rowIndex dataset1 dataset2 -b start# -e end#

Copy from rowIndex# of dataset1 to dataset2, beginning at the dataset2 start# and ending at end#.The destination range must be within the existing range of dataset2, and the source range must not go outside the existing range of dataset1.

-f;Copy dataset1 to dataset2 but remove the first point and swap the two halves of dataset2

Syntax: copy -f dataset1 dataset2

Copy dataset1 to dataset2 but remove the first point and swap the two halves of dataset2.This option reverses the effects of the -m option if applied to each of the new datasets.

-m;Copy the odd entries of dataset1 to dataset2 and the even entries to dataset3

Syntax: copy -m dataset1 dataset2 dataset3

Copy the odd entries of dataset1 to dataset2 and the even entries to dataset3.To use this command, there should be a multiple of 4 points in dataset1, the source dataset. If n is the number of rows in dataset1, take the cell value in row index n/2+1 in dataset1 and copy this value to row index n/2+1 in dataset2.Take the cell value in row index n/2+2 in dataset1 and copy this value to row index n/2+1 in dataset3.Dataset2 and dataset3 now have n/2+1 points.Excluding the last row in dataset2 and dataset3 (row index n/2+1), move the first half of each dataset to the end (n/2) of the dataset.

-s;Set dataset2 to a size of npts

Syntax: copy -s npts dataset1 dataset2

Set dataset2 to a size of npts. Copy dataset1 into dataset2 such that the entire range of dataset1 is interpolated to fit into dataset2 with npts.

Note: This command works only when the destination dataset does not have an associated X column.

-u;Split (unzip) dataset1 into dataset2 and dataset3

Syntax: copy -u dataset1 dataset2 dataset3

Split (unzip) dataset1 into dataset2 and dataset3 so that the first point in dataset1 becomes the first point in dataset2, the second point in dataset1 becomes the first point in dataset3, etc.Reverse of the -z option.

-w; Copy FunctionShortName in GraphLayerRangeString to YcolumnDatasetName

Syntax: copy -w GraphLayerRangeString FunctionShortName YcolumnDatasetName

Copy loose dataset FunctionShortName in GraphLayerRangeString to Y column YcolumnDatasetName. Copy the corresponding X column. GraphLayerRangeString can be the graph page short name (e.g. "Graph1") or it can be a range string (e.g. "[Graph1]1!"). For more on range syntax, see Range Notation.

The -w switch was added to make a dataset copy of a 2D function and paste it to the named Y column in a workbook created from the func2d.otw template. See window -t WF.

-x;Copy dataset1 to dataset2,Copy the corresponding X dataset if it exists.

Syntax: copy -x dataset1 dataset2

Copy dataset1 to dataset2 where dataset2 is in a different worksheet.Copy the corresponding X dataset if it exists.

-z;Combine (zip) dataset1 and dataset2 and copy into dataset3

Syntax: copy -z dataset1 dataset2 dataset3

Combine (zip) dataset1 and dataset2 and copy into dataset3 such that the first point in dataset3 is the first point in dataset1, the second point in dataset3 is the first point in dataset2, etc.Reverse of the -u option.

Examples:

Example 1:

The following script copies Book1_B to Book2_D and copies the X column of Book1_B to the X column of Book2_D.

copy -x Book1_B Book2_D;

Example 2:

The next two scripts copy 20 points from Book1_B (74 - 55 + 1), beginning at the 13th row, to Book1_F beginning at the 55th row.

// Use -begin -end notation for range
copy -b 13 Book1_B Book1_F -b 55 -e 74; 
// Use -begin -total notation for range
copy -b 13 Book1_B Book1_F -b 55 -t 20;

Example 3:

Given an even number of values in column A, the next script creates odd and even 'folded' datasets (book1_b and book1_c), then 'unfolds' them (book1_d and book1_e) and combines these to re-create the original dataset (book1_f = book1_a). The number of rows in book1_a should be a multiple of four.

copy -m book1_a book1_b book1_c;  // Splits and folds odd and even rows
copy -f book1_b book1_d;          // Unfolds B
copy -f book1_c book1_e;          // Unfolds C
// Interleaves D and E to reproduce A in F
copy -z book1_d book1_e book1_f;

Example 4:

Copy a dataset with 7 values into a new dataset with 19 values. The interpolation size is (7-1)/(19-1) or .333 which means that 0 to 3 and 3 to 6 (differences of 3 each) will be interpolated in steps of 1 ( 3 * .333 ~ 1) and 8 to 4 and 4 to 0 (differences of 4 each) will be interpolated in steps of 1.333 ( 4 * .333 ~ 1.333)

col(A) = {0,3,6,7,8,4,0};
copy -s 41 col(A) temp;
copy temp col(B);

Example 5:

Append one dataset to another. Copy the appended datasets to a new column and sort, then unzip the data such that odd rows are in one new column and even rows are in a second new column.

col(A) = {8,2,4,0,6};
col(B) = {7,3,9,1,5};
copy -a col(B) col(A);
col(C) = sort(col(A));
copy -u col(C) col(D) col(E);