-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
53 lines (47 loc) · 912 Bytes
/
main.go
File metadata and controls
53 lines (47 loc) · 912 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
type xy struct {
x, y float64
}
func main() {
var xys []xy
f, err := os.Open("./data.txt")
if err != nil {
fmt.Errorf("unable to opem file%v", err)
}
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
xyline := scanner.Text()
xys = append(xys, fmtxys(xyline))
fmt.Println(xys)
}
}
func fmtxys(xyline string) xy {
var txy xy
xyArray:= strings.Split(xyline, ",")
txy.x= xyarr[0]
txy.=
}
func rxys(cyCompl []xy) plotter.XYs {
xy1 := make(plotter.XYs, len(xyComppl))
var err error
xyArray := strings.Split(xyline, ",")
for xy := range xyArray {
xy1.x, err = strconv.ParseFloat(xyArray[0], 64)
if err != nil {
fmt.Errorf("unable to convert xy.x%v", err)
}
xy1.y, err = strconv.ParseFloat(xyArray[1], 64)
if err != nil {
fmt.Errorf("unable to convert xy.y%v", err)
}
}
return xy
}