2023-01-18 09:17:36 +02:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
2023-01-19 07:10:14 +02:00
|
|
|
|
"os"
|
2023-01-18 09:17:36 +02:00
|
|
|
|
|
2023-01-19 07:10:14 +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() {
|
2023-01-19 07:10:14 +02:00
|
|
|
|
var inTest []model.MTType
|
|
|
|
|
var outTest []model.MTParseT
|
2023-01-19 11:13:08 +02:00
|
|
|
|
filename := util.InputTerminal("Введите имя файла базы данных сохранненой с сайта для парсинга (json)")
|
|
|
|
|
|
2023-01-19 11:20:20 +02:00
|
|
|
|
bs, err := os.ReadFile(filename + ".json")
|
2023-01-19 11:13:08 +02:00
|
|
|
|
util.Check(err, "")
|
2023-01-18 09:17:36 +02:00
|
|
|
|
|
2023-01-19 07:10:14 +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
|
|
|
|
|
2023-01-19 07:10:14 +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
|
|
|
|
}
|