Merging with master
This commit is contained in:
@@ -309,6 +309,9 @@ func main() {
|
|||||||
SaveToCsvFile(exportingData, keyMap, *outputPath, *fullExport)
|
SaveToCsvFile(exportingData, keyMap, *outputPath, *fullExport)
|
||||||
case ".json":
|
case ".json":
|
||||||
SaveToJSONFile(exportingData, keyMap, *outputPath, *fullExport)
|
SaveToJSONFile(exportingData, keyMap, *outputPath, *fullExport)
|
||||||
|
case ".jsl":
|
||||||
|
SaveToJSLFile(exportingData, keyMap, *outputPath, *fullExport)
|
||||||
|
|
||||||
case ".csv.gz":
|
case ".csv.gz":
|
||||||
SaveToCsvGzFile(exportingData, keyMap, *outputPath, *fullExport)
|
SaveToCsvGzFile(exportingData, keyMap, *outputPath, *fullExport)
|
||||||
case ".json.gz":
|
case ".json.gz":
|
||||||
|
|||||||
@@ -103,6 +103,49 @@ func SaveToJSONFile(data []StatForTime, keyMap map[uint8]string, path string, fu
|
|||||||
SaveToJSONWriter(data, keyMap, jsonFile, fullExport)
|
SaveToJSONWriter(data, keyMap, jsonFile, fullExport)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SaveToJSLWriter(data []StatForTime, keyMap map[uint8]string, writerOut io.Writer, fullExport bool) {
|
||||||
|
type JSLStatForTime struct {
|
||||||
|
Time int64
|
||||||
|
Keys map[string]int
|
||||||
|
}
|
||||||
|
|
||||||
|
table := make([]JSLStatForTime, len(data))
|
||||||
|
for i, stat := range data {
|
||||||
|
table[i].Keys = make(map[string]int)
|
||||||
|
|
||||||
|
table[i].Time = stat.time
|
||||||
|
var sum int
|
||||||
|
for numKey, key := range keyMap {
|
||||||
|
if fullExport {
|
||||||
|
table[i].Keys[key] = stat.keys[numKey]
|
||||||
|
}
|
||||||
|
sum += stat.keys[numKey]
|
||||||
|
}
|
||||||
|
table[i].Keys["sum"] = sum
|
||||||
|
}
|
||||||
|
|
||||||
|
for ind, line := range table {
|
||||||
|
lineBytes, err := json.Marshal(line)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
writerOut.Write(lineBytes)
|
||||||
|
if ind != len(table)-1 {
|
||||||
|
writerOut.Write([]byte("\n"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SaveToJSLFile(data []StatForTime, keyMap map[uint8]string, path string, fullExport bool) {
|
||||||
|
jslFile, err := os.Create(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer jslFile.Close()
|
||||||
|
|
||||||
|
SaveToJSLWriter(data, keyMap, jslFile, fullExport)
|
||||||
|
}
|
||||||
|
|
||||||
func SaveToCsvGzFile(data []StatForTime, keyMap map[uint8]string, path string, fullExport bool) {
|
func SaveToCsvGzFile(data []StatForTime, keyMap map[uint8]string, path string, fullExport bool) {
|
||||||
jsonFile, err := os.Create(path)
|
jsonFile, err := os.Create(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user