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

Method RowsByStringIndex

tensor/table/table.go:402–424  ·  view source on GitHub ↗

RowsByStringIndex returns the list of rows that have given string value in given column index. if contains, only checks if row contains string; if ignoreCase, ignores case. Use named args for greater clarity.

(column int, str string, contains, ignoreCase bool)

Source from the content-addressed store, hash-verified

400// if contains, only checks if row contains string; if ignoreCase, ignores case.
401// Use named args for greater clarity.
402func (dt *Table) RowsByStringIndex(column int, str string, contains, ignoreCase bool) []int {
403 col := dt.Columns[column]
404 lowstr := strings.ToLower(str)
405 var idxs []int
406 for i := 0; i < dt.Rows; i++ {
407 val := col.String1D(i)
408 has := false
409 switch {
410 case contains && ignoreCase:
411 has = strings.Contains(strings.ToLower(val), lowstr)
412 case contains:
413 has = strings.Contains(val, str)
414 case ignoreCase:
415 has = strings.EqualFold(val, str)
416 default:
417 has = (val == str)
418 }
419 if has {
420 idxs = append(idxs, i)
421 }
422 }
423 return idxs
424}
425
426// RowsByString returns the list of rows that have given
427// string value in given column name. returns nil if name invalid -- see also Try.

Callers 1

RowsByStringMethod · 0.95

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 2

String1DMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected