FromMimeData returns records from csv of mime data
(md mimedata.Mimes)
| 684 | |
| 685 | // FromMimeData returns records from csv of mime data |
| 686 | func (tb *Table) FromMimeData(md mimedata.Mimes) [][]string { |
| 687 | var recs [][]string |
| 688 | for _, d := range md { |
| 689 | if d.Type == fileinfo.DataCsv { |
| 690 | b := bytes.NewBuffer(d.Data) |
| 691 | cr := csv.NewReader(b) |
| 692 | cr.Comma = table.Tab.Rune() |
| 693 | rec, err := cr.ReadAll() |
| 694 | if err != nil || len(rec) == 0 { |
| 695 | log.Printf("Error reading CSV from clipboard: %s\n", err) |
| 696 | return nil |
| 697 | } |
| 698 | recs = append(recs, rec...) |
| 699 | } |
| 700 | } |
| 701 | return recs |
| 702 | } |
| 703 | |
| 704 | // PasteAssign assigns mime data (only the first one!) to this idx |
| 705 | func (tb *Table) PasteAssign(md mimedata.Mimes, idx int) { |
no test coverage detected