MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / Column

Method Column

pkg/tabular/tabular.go:111–132  ·  view source on GitHub ↗

Column returns the values of the column whose header matches name case-insensitively (trimming surrounding whitespace), with empty and whitespace-only cells dropped, and whether such a column exists.

(name string)

Source from the content-addressed store, hash-verified

109// case-insensitively (trimming surrounding whitespace), with empty and
110// whitespace-only cells dropped, and whether such a column exists.
111func (t *Table) Column(name string) ([]string, bool) {
112 var header string
113 found := false
114 for _, h := range t.Header {
115 if strings.EqualFold(strings.TrimSpace(h), strings.TrimSpace(name)) {
116 header = h
117 found = true
118 break
119 }
120 }
121 if !found {
122 return nil, false
123 }
124
125 values := make([]string, 0, len(t.Rows))
126 for _, row := range t.Rows {
127 if v := strings.TrimSpace(row[header]); v != "" {
128 values = append(values, v)
129 }
130 }
131 return values, true
132}
133
134// decode normalizes the input to UTF-8, using the BOM (if any) to detect
135// UTF-16; defaults to UTF-8 when no BOM is present, stripping a UTF-8 BOM.

Callers 2

TestColumnFunction · 0.80
extractCSVColumnFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestColumnFunction · 0.64