MCPcopy
hub / github.com/daptin/daptin / Read

Method Read

server/csvmap/csvmap.go:31–44  ·  view source on GitHub ↗

Read wraps csv.Reader.Read, creating a map of column name to field value. If the line has fewer columns than Reader.Columns, the map will not contain keys for these columns; thus we can distinguish between missing columns and columns with empty values. If the line has more columns than Reader.Column

()

Source from the content-addressed store, hash-verified

29// thus we can distinguish between missing columns and columns with empty values.
30// If the line has more columns than Reader.Columns, Reader.Read() ignores them.
31func (r *Reader) Read() (record map[string]string, err error) {
32 var rawRecord []string
33 rawRecord, err = r.Reader.Read()
34 length := min(len(rawRecord), len(r.Columns))
35 record = make(map[string]string)
36 for index := 0; index < length; index++ {
37 column := r.Columns[index]
38 if _, exists := record[column]; exists {
39 return nil, fmt.Errorf("Multiple indices with the same name '%s'", column)
40 }
41 record[column] = rawRecord[index]
42 }
43 return
44}
45
46// ReadAll reads all the remaining records from r. Each record is a map of column name to field value.
47func (r *Reader) ReadAll() (records []map[string]string, err error) {

Callers 5

ReadAllMethod · 0.95
FtpTestFunction · 0.45
UnmarshalBinaryMethod · 0.45
UnmarshalBinaryMethod · 0.45
ReadHeaderMethod · 0.45

Calls 2

minFunction · 0.85
makeFunction · 0.85

Tested by 1

FtpTestFunction · 0.36