Copy Cell CopyCell copies into cell at given column, row from cell in other table. It is robust to differences in type; uses destination cell type. Returns error if column names are invalid.
(column string, row int, cpt *Table, cpColNm string, cpRow int)
| 689 | // It is robust to differences in type; uses destination cell type. |
| 690 | // Returns error if column names are invalid. |
| 691 | func (dt *Table) CopyCell(column string, row int, cpt *Table, cpColNm string, cpRow int) bool { |
| 692 | ct := dt.ColumnByName(column) |
| 693 | if ct == nil { |
| 694 | return false |
| 695 | } |
| 696 | cpct := cpt.ColumnByName(cpColNm) |
| 697 | if cpct == nil { |
| 698 | return false |
| 699 | } |
| 700 | _, sz := ct.RowCellSize() |
| 701 | if sz == 1 { |
| 702 | if ct.IsString() { |
| 703 | ct.SetString1D(row, cpct.String1D(cpRow)) |
| 704 | } else { |
| 705 | ct.SetFloat1D(row, cpct.Float1D(cpRow)) |
| 706 | } |
| 707 | } else { |
| 708 | _, cpsz := cpct.RowCellSize() |
| 709 | st := row * sz |
| 710 | cst := cpRow * cpsz |
| 711 | msz := min(sz, cpsz) |
| 712 | if ct.IsString() { |
| 713 | for j := 0; j < msz; j++ { |
| 714 | ct.SetString1D(st+j, cpct.String1D(cst+j)) |
| 715 | } |
| 716 | } else { |
| 717 | for j := 0; j < msz; j++ { |
| 718 | ct.SetFloat1D(st+j, cpct.Float1D(cst+j)) |
| 719 | } |
| 720 | } |
| 721 | } |
| 722 | return true |
| 723 | } |
no test coverage detected