OpenCSV reads a table from a comma-separated-values (CSV) file (where comma = any delimiter, specified in the delim arg), using the Go standard encoding/csv reader conforming to the official CSV standard. If the table does not currently have any columns, the first row of the file is assumed to be he
(filename core.Filename, delim Delims)
| 108 | // If the table DOES have existing columns, then those are used robustly |
| 109 | // for whatever information fits from each row of the file. |
| 110 | func (dt *Table) OpenCSV(filename core.Filename, delim Delims) error { //types:add |
| 111 | fp, err := os.Open(string(filename)) |
| 112 | if err != nil { |
| 113 | return errors.Log(err) |
| 114 | } |
| 115 | defer fp.Close() |
| 116 | return dt.ReadCSV(bufio.NewReader(fp), delim) |
| 117 | } |
| 118 | |
| 119 | // OpenFS is the version of [Table.OpenCSV] that uses an [fs.FS] filesystem. |
| 120 | func (dt *Table) OpenFS(fsys fs.FS, filename string, delim Delims) error { |