NewTabularDataLoader creates a new TabularDataLoader to insert into the specified |table| using the specified |delimiterChar| and |nullChar|. If |header| is true, the first line of the data will be treated as a header and ignored.
(colNames []string, tableSch sql.Schema, delimiterChar, nullChar string, header bool)
| 46 | // |delimiterChar| and |nullChar|. If |header| is true, the first line of the data will be treated as a header and |
| 47 | // ignored. |
| 48 | func NewTabularDataLoader(colNames []string, tableSch sql.Schema, delimiterChar, nullChar string, header bool) (*TabularDataLoader, error) { |
| 49 | colTypes, reducedSch, err := getColumnTypes(colNames, tableSch) |
| 50 | if err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | |
| 54 | if delimiterChar == "" { |
| 55 | delimiterChar = defaultTextDelimiter |
| 56 | } |
| 57 | |
| 58 | if nullChar == "" { |
| 59 | nullChar = defaultNullChar |
| 60 | } |
| 61 | |
| 62 | return &TabularDataLoader{ |
| 63 | colTypes: colTypes, |
| 64 | sch: reducedSch, |
| 65 | delimiterChar: delimiterChar, |
| 66 | nullChar: nullChar, |
| 67 | removeHeader: header, |
| 68 | }, nil |
| 69 | } |
| 70 | |
| 71 | // nextRow returns the next SQL row from the reader provided, using any previously saved partial line. Returns true if |
| 72 | // there was another row. |