ReadCSVRow reads a record of CSV data into given row in table
(rec []string, row int)
| 186 | |
| 187 | // ReadCSVRow reads a record of CSV data into given row in table |
| 188 | func (dt *Table) ReadCSVRow(rec []string, row int) { |
| 189 | tc := dt.NumColumns() |
| 190 | ci := 0 |
| 191 | if rec[0] == "_D:" { // data row |
| 192 | ci++ |
| 193 | } |
| 194 | nan := math.NaN() |
| 195 | for j := 0; j < tc; j++ { |
| 196 | tsr := dt.Columns[j] |
| 197 | _, csz := tsr.RowCellSize() |
| 198 | stoff := row * csz |
| 199 | for cc := 0; cc < csz; cc++ { |
| 200 | str := rec[ci] |
| 201 | if !tsr.IsString() { |
| 202 | if str == "" || str == "NaN" || str == "-NaN" || str == "Inf" || str == "-Inf" { |
| 203 | tsr.SetFloat1D(stoff+cc, nan) |
| 204 | } else { |
| 205 | tsr.SetString1D(stoff+cc, strings.TrimSpace(str)) |
| 206 | } |
| 207 | } else { |
| 208 | tsr.SetString1D(stoff+cc, strings.TrimSpace(str)) |
| 209 | } |
| 210 | ci++ |
| 211 | if ci >= len(rec) { |
| 212 | return |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | // ConfigFromHeaders attempts to configure Table based on the headers. |
| 219 | // for non-table headers, data is examined to determine types. |
no test coverage detected