|
|
@ -6,7 +6,7 @@ import ( |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
func readDataFile(path string, lineSeparation string, valueSeparation string) [][][]int { |
|
|
|
func readDataset(path string, lineSeparation string, valueSeparation string) [][][]int { |
|
|
|
var dataset [][][]int |
|
|
|
b, err := ioutil.ReadFile(path) |
|
|
|
check(err) |
|
|
@ -33,3 +33,26 @@ func readDataFile(path string, lineSeparation string, valueSeparation string) [] |
|
|
|
} |
|
|
|
return dataset |
|
|
|
} |
|
|
|
|
|
|
|
func readInputs(path string, lineSeparation string, valueSeparation string) [][]int { |
|
|
|
var dataset [][]int |
|
|
|
b, err := ioutil.ReadFile(path) |
|
|
|
check(err) |
|
|
|
str := string(b) |
|
|
|
str = strings.Replace(str, "\r", "", -1) |
|
|
|
lines := strings.Split(str, lineSeparation) |
|
|
|
for _, v1 := range lines { |
|
|
|
params := strings.Split(v1, valueSeparation) |
|
|
|
//var datasetLine [][]int
|
|
|
|
var datasetLineEntry []int |
|
|
|
for _, v2 := range params { |
|
|
|
value, err := strconv.Atoi(v2) |
|
|
|
check(err) |
|
|
|
datasetLineEntry = append(datasetLineEntry, value) |
|
|
|
|
|
|
|
} |
|
|
|
//datasetLine = append(datasetLine, datasetLineEntry)
|
|
|
|
dataset = append(dataset, datasetLineEntry) |
|
|
|
} |
|
|
|
return dataset |
|
|
|
} |