MCPcopy Create free account
hub / github.com/cogentcore/core / ReadCSVRow

Method ReadCSVRow

tensor/table/io.go:188–216  ·  view source on GitHub ↗

ReadCSVRow reads a record of CSV data into given row in table

(rec []string, row int)

Source from the content-addressed store, hash-verified

186
187// ReadCSVRow reads a record of CSV data into given row in table
188func (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.

Callers 3

ReadCSVMethod · 0.95
PasteAssignMethod · 0.80
PasteAtIndexMethod · 0.80

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 5

NumColumnsMethod · 0.95
RowCellSizeMethod · 0.65
IsStringMethod · 0.65
SetFloat1DMethod · 0.65
SetString1DMethod · 0.65

Tested by

no test coverage detected