Skip to content
Snippets Groups Projects
Commit aaa89879 authored by Bart Vercoulen's avatar Bart Vercoulen
Browse files

Fixed collectDetailMetricsFromReader to handle a row with an empty user value.

parent d0015cea
Branches
No related tags found
No related merge requests found
...@@ -123,7 +123,7 @@ func collectDetailMetricsFromReader(reader io.Reader, scope string, ch chan<- pr ...@@ -123,7 +123,7 @@ func collectDetailMetricsFromReader(reader io.Reader, scope string, ch chan<- pr
if !scanner.Scan() { if !scanner.Scan() {
return fmt.Errorf("Failed to extract columns from input") return fmt.Errorf("Failed to extract columns from input")
} }
columnNames := strings.Fields(scanner.Text()) columnNames := strings.Split(scanner.Text(), "\t")
if len(columnNames) < 2 { if len(columnNames) < 2 {
return fmt.Errorf("Input does not provide any columns") return fmt.Errorf("Input does not provide any columns")
} }
...@@ -144,10 +144,13 @@ func collectDetailMetricsFromReader(reader io.Reader, scope string, ch chan<- pr ...@@ -144,10 +144,13 @@ func collectDetailMetricsFromReader(reader io.Reader, scope string, ch chan<- pr
break break
} }
values := strings.Fields(row) values := strings.Split(row, "\t")
if len(values) != len(columns)+1 { if len(values) != len(columns)+1 {
return fmt.Errorf("error while parsing rows: value count does not match column count") return fmt.Errorf("error while parsing rows: value count does not match column count")
} }
if values[0] == "" {
values[0] = "empty_user"
}
for i, value := range values[1:] { for i, value := range values[1:] {
f, err := strconv.ParseFloat(value, 64) f, err := strconv.ParseFloat(value, 64)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment