Added saving to json.gz and csv.gz
This commit is contained in:
@@ -309,6 +309,10 @@ func main() {
|
||||
SaveToCsvFile(exportingData, keyMap, *outputPath, *fullExport)
|
||||
case ".json":
|
||||
SaveToJSONFile(exportingData, keyMap, *outputPath, *fullExport)
|
||||
case ".csv.gz":
|
||||
SaveToCsvGzFile(exportingData, keyMap, *outputPath, *fullExport)
|
||||
case ".json.gz":
|
||||
SaveToJSONGzFile(exportingData, keyMap, *outputPath, *fullExport)
|
||||
default:
|
||||
log.Fatal("Incorrect file type")
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"io"
|
||||
@@ -101,3 +102,29 @@ func SaveToJSONFile(data []StatForTime, keyMap map[uint8]string, path string, fu
|
||||
|
||||
SaveToJSONWriter(data, keyMap, jsonFile, fullExport)
|
||||
}
|
||||
|
||||
func SaveToCsvGzFile(data []StatForTime, keyMap map[uint8]string, path string, fullExport bool) {
|
||||
jsonFile, err := os.Create(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer jsonFile.Close()
|
||||
|
||||
gzipWriter := gzip.NewWriter(jsonFile)
|
||||
defer gzipWriter.Close()
|
||||
|
||||
SaveToCsvWriter(data, keyMap, gzipWriter, fullExport)
|
||||
}
|
||||
|
||||
func SaveToJSONGzFile(data []StatForTime, keyMap map[uint8]string, path string, fullExport bool) {
|
||||
jsonFile, err := os.Create(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer jsonFile.Close()
|
||||
|
||||
gzipWriter := gzip.NewWriter(jsonFile)
|
||||
defer gzipWriter.Close()
|
||||
|
||||
SaveToJSONWriter(data, keyMap, gzipWriter, fullExport)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user