mchstest/cmd/mtparse/main.go

34 lines
782 B
Go
Raw Normal View History

2023-01-18 09:17:36 +02:00
package main
import (
"encoding/json"
"io/ioutil"
"os"
2023-01-18 09:17:36 +02:00
"gitstore.ru/tolikproh/mchstest/internal/model"
2023-01-19 11:13:08 +02:00
"gitstore.ru/tolikproh/mchstest/pkg/util"
2023-01-18 09:17:36 +02:00
)
func main() {
var inTest []model.MTType
var outTest []model.MTParseT
2023-01-19 11:13:08 +02:00
filename := util.InputTerminal("Введите имя файла базы данных сохранненой с сайта для парсинга (json)")
bs, err := ioutil.ReadFile(filename + ".json")
util.Check(err, "")
2023-01-18 09:17:36 +02:00
err = json.Unmarshal(bs, &inTest)
2023-01-19 11:13:08 +02:00
util.Check(err, "")
2023-01-18 09:17:36 +02:00
for _, in := range inTest {
outTest = append(outTest, in.Parse())
2023-01-18 09:17:36 +02:00
}
2023-01-19 11:13:08 +02:00
model.SaveToExel(filename+".xlsx", &outTest)
outTestJSON, err := json.Marshal(outTest)
util.Check(err, "")
err = os.WriteFile(filename+"_parse.json", outTestJSON, 0644)
util.Check(err, "")
2023-01-18 09:17:36 +02:00
}