MCPcopy Create free account
hub / github.com/brimdata/super / NewReader

Function NewReader

sio/csvio/reader.go:37–54  ·  view source on GitHub ↗

XXX This is a placeholder for an option that will allow one to convert all csv fields to strings and defer any type coercion presumably to SuperSQL shapers. Currently, this causes an import cycle because the csvio Writer depends on fuse. We should refactor this so whatever logic wants to tack on a

(sctx *super.Context, r io.Reader, opts ReaderOpts)

Source from the content-addressed store, hash-verified

35//}
36
37func NewReader(sctx *super.Context, r io.Reader, opts ReaderOpts) *Reader {
38 preprocess := newPreprocess(r, opts.Delim)
39 reader := csv.NewReader(preprocess)
40 if opts.Delim != 0 {
41 reader.Comma = opts.Delim
42 }
43 if !unicode.IsSpace(reader.Comma) {
44 // TrimLeadingSpace will trim leading and trailing space characters
45 // even if the delimiter is a space character so only enable this if
46 // reader.Comma is not a space character.
47 reader.TrimLeadingSpace = true
48 }
49 reader.ReuseRecord = true
50 return &Reader{
51 reader: reader,
52 marshaler: sup.NewBSUPMarshalerWithContext(sctx),
53 }
54}
55
56func (r *Reader) Read() (*super.Value, error) {
57 for {

Callers 4

NewReaderFunction · 0.92
isCSVStreamFunction · 0.92
lookupReaderFunction · 0.92

Calls 3

newPreprocessFunction · 0.85
NewReaderMethod · 0.45

Tested by 1