blob: c5992a7632294443def3c152dc7e53ebc8475606 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package file
import (
"encoding/csv"
"git.darknebu.la/bit/logplus"
"os"
)
type File struct {
f *os.File
}
func Open(path string) (File, error) {
file, err := os.Open(path)
if err != nil {
logplus.LogErrorf("openStarsCSV Panic! (cannot read file from %s)\n", path)
}
return File{f: file}, err
}
func (file *File) ReadCSV() ([][]string, error) {
lines, err := csv.NewReader(file.f).ReadAll()
if err != nil {
logplus.LogErrorf("openStarsCSV Panic! (cannot read the files content)\n")
}
return lines, err
}
func (file *File) Close() error {
return file.f.Close()
}
|