Rows returns the rows in datatable Computes all expressions.
(opt ...ExportOption)
| 116 | // Rows returns the rows in datatable |
| 117 | // Computes all expressions. |
| 118 | func (t *DataTable) Rows(opt ...ExportOption) []Row { |
| 119 | if t == nil { |
| 120 | return nil |
| 121 | } |
| 122 | |
| 123 | opts := newExportOptions(opt...) |
| 124 | if err := t.evaluateExpressions(); err != nil { |
| 125 | panic(err) |
| 126 | } |
| 127 | |
| 128 | // visible columns |
| 129 | cols := make(map[string]int) |
| 130 | for i, col := range t.cols { |
| 131 | if opts.WithHiddenCols || col.IsVisible() { |
| 132 | cols[col.Name()] = i |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | rows := make([]Row, 0, t.nrows) |
| 137 | for i := 0; i < t.nrows; i++ { |
| 138 | r := make(Row, len(cols)) |
| 139 | for name, pos := range cols { |
| 140 | r[name] = t.cols[pos].serie.Get(i) |
| 141 | } |
| 142 | rows = append(rows, r) |
| 143 | } |
| 144 | return rows |
| 145 | } |
| 146 | |
| 147 | func (t *DataTable) String() string { |
| 148 | var sb strings.Builder |