// Read will construct a DataFrame from the data read off the Reader.
Read will construct a DataFrame from the data read off the Reader.
// Read will construct a DataFrame from the data read off the Reader .
func (dfr *DFReader) Read(rd io.Reader, source string) (*DF, error) {
	df, err := dfr.makeDF()
	if err != nil {
		return nil, err
	}
	state := newDFReadState(dfr, source)
	operations := []lineHandler{
		skipLine,
		stripComments,
		skipBlankLine,
		splitLine,
		handleLine1,
		checkColumns,
		cacheData,
		handleData,
	}
	scanner := bufio.NewScanner(rd)
Loop:
	for scanner.Scan() {
		state.loc.Incr()
		state.line = scanner.Text()
		for _, op := range operations {
			skip, err := op(dfr, state, df)
			if err != nil {
				return nil, err
			}
			if skip {
				continue Loop
			}
		}
	}
	if err = scanner.Err(); err != nil {
		return nil, err
	}
	err = populateDF(dfr, state, df)
	if !dfr.allowErrors && err != nil {
		return nil, err
	}
	return df, nil
}
func ( dfr * DFReader ) Read ( rd io . Reader , source string ) ( * DF , error ) { df , err := dfr . makeDF ( ) if err != nil { return nil , err } state := newDFReadState ( dfr , source ) operations := [ ] lineHandler { skipLine , stripComments , skipBlankLine , splitLine , handleLine1 , checkColumns , cacheData , handleData , } scanner := bufio . NewScanner ( rd ) Loop : for scanner . Scan ( ) { state . loc . Incr ( ) state . line = scanner . Text ( ) for _ , op := range operations { skip , err := op ( dfr , state , df ) if err != nil { return nil , err } if skip { continue Loop } } } if err = scanner . Err ( ) ; err != nil { return nil , err } err = populateDF ( dfr , state , df ) if ! dfr . allowErrors && err != nil { return nil , err } return df , nil }
Read will construct a DataFrame from the data read off the Reader.
Read will construct a DataFrame from the data read off the Reader .