-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (45 loc) · 1.13 KB
/
main.go
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
54
55
56
57
58
59
60
61
62
63
package main
import (
"encoding/csv"
"log"
"os"
"github.com/thiagocamargodacosta/dass-21/exporter"
"github.com/thiagocamargodacosta/dass-21/form"
"github.com/thiagocamargodacosta/dass-21/reporting"
"github.com/thiagocamargodacosta/dass-21/scoring"
)
const filename = "DASS-21 (respostas) - Respostas ao formulário 1.csv"
const output = "dass-21-scoring-results.csv"
func main() {
// Open input csv
f, err := os.Open(filename)
if err != nil {
log.Fatal(err)
}
defer f.Close()
// Read the csv file
csvReader := csv.NewReader(f)
data, err := csvReader.ReadAll()
if err != nil {
log.Fatal(err)
}
// Convert csv to slice
forms := form.CreateForms(data)
reports := make([]reporting.Report, len(forms))
for i, entry := range forms {
var s scoring.Score = scoring.DASS(entry)
var r reporting.Report = reporting.Report{
Date: entry.Date,
Email: entry.Email,
Depression: s.Depression,
Anxiety: s.Anxiety,
Stress: s.Stress,
}
reporting.Print(r)
reports[i] = r
}
err = exporter.WriteOutputCSV(output, reports)
if err != nil {
log.Fatalf("error while writing output csv", err)
}
}