Browse Source

csv output

Dmitry Yu Okunev 7 years ago
parent
commit
43500ed7d6
2 changed files with 8 additions and 2 deletions
  1. 6 1
      main.go
  2. 2 1
      voltloggerParser/voltloggerParser.go

+ 6 - 1
main.go

@@ -26,7 +26,12 @@ func handleHeader(h voltloggerParser.VoltloggerDumpHeader, arg_iface interface{}
 }
 
 func printRow(ts int64, row []int, h voltloggerParser.VoltloggerDumpHeader, arg_iface interface{}) (error) {
-	fmt.Printf("row[%v]: %v\n", ts, row);
+	fmt.Printf("%v", ts)
+	rowLen := len(row)
+	for i:=0; i < rowLen; i++ {
+		fmt.Printf("\t%v", row[i])
+	}
+	fmt.Printf("\n")
 	return nil
 }
 

+ 2 - 1
voltloggerParser/voltloggerParser.go

@@ -4,6 +4,7 @@ import (
 	"os"
 	"io"
 	"fmt"
+	"strings"
 	"encoding/binary"
 )
 /*
@@ -63,7 +64,7 @@ func ParseVoltloggerDump(dumpPath string, headerHandler func(VoltloggerDumpHeade
 
 	// Filling the VoltloggerDump struct
 	var r VoltloggerDumpHeader
-	r.DeviceName = string(raw.DeviceName[:])
+	r.DeviceName = strings.Trim(string(raw.DeviceName[:]), "\000")
 
 	err = headerHandler(r, arg);
 	if (err != nil) {