提交 2bac92d6 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

import data

上级 e98eada5
......@@ -58,3 +58,21 @@ func GetExcelTable(filePath, sheetName string) (records []map[string]interface{}
return
}
func GetExcelFirstSheet(filePath string) (sheetName string, rows [][]string) {
excel, err := excelize.OpenFile(filePath)
if err != nil {
fmt.Printf("fail to read file %s, error: %s", filePath, err.Error())
return
}
sheetName = excel.GetSheetList()[0]
rows, err = excel.GetRows(sheetName)
if err != nil {
fmt.Println(err)
}
return
}
......@@ -2,8 +2,8 @@ package main
import (
"fmt"
"github.com/easysoft/zendata/src/test/import/comm"
"github.com/easysoft/zendata/src/test/import/model"
"github.com/easysoft/zendata/cmd/test/import/comm"
"github.com/easysoft/zendata/cmd/test/import/model"
)
func main() {
......
......@@ -2,8 +2,8 @@ package main
import (
"fmt"
"github.com/easysoft/zendata/internal/pkg/test/import/comm"
"github.com/easysoft/zendata/internal/pkg/test/import/model"
"github.com/easysoft/zendata/cmd/test/import/comm"
"github.com/easysoft/zendata/cmd/test/import/model"
)
func main() {
......
......@@ -2,8 +2,8 @@ package main
import (
"fmt"
"github.com/easysoft/zendata/internal/pkg/test/import/comm"
"github.com/easysoft/zendata/internal/pkg/test/import/model"
"github.com/easysoft/zendata/cmd/test/import/comm"
"github.com/easysoft/zendata/cmd/test/import/model"
stringUtils "github.com/easysoft/zendata/pkg/utils/string"
)
......
......@@ -2,8 +2,8 @@ package main
import (
"fmt"
"github.com/easysoft/zendata/internal/pkg/test/import/comm"
"github.com/easysoft/zendata/internal/pkg/test/import/model"
"github.com/easysoft/zendata/cmd/test/import/comm"
"github.com/easysoft/zendata/cmd/test/import/model"
stringUtils "github.com/easysoft/zendata/pkg/utils/string"
)
......
......@@ -2,8 +2,8 @@ package main
import (
"fmt"
"github.com/easysoft/zendata/internal/pkg/test/import/comm"
"github.com/easysoft/zendata/internal/pkg/test/import/model"
"github.com/easysoft/zendata/cmd/test/import/comm"
"github.com/easysoft/zendata/cmd/test/import/model"
)
func main() {
......
......@@ -2,8 +2,8 @@ package main
import (
"fmt"
"github.com/easysoft/zendata/internal/pkg/test/import/comm"
"github.com/easysoft/zendata/internal/pkg/test/import/model"
"github.com/easysoft/zendata/cmd/test/import/comm"
"github.com/easysoft/zendata/cmd/test/import/model"
)
func main() {
......
......@@ -34,7 +34,7 @@ func main() {
logs := []string{}
for i, path := range filePathArr {
sheetName, count := ImoprtWordsFromExcel(path, db)
sheetName, count := ImportWordsFromExcel(path, db)
str := fmt.Sprintf("%d) Path:[%s] SheetName:[%s], count:[%d]\n", i, path, sheetName, count)
fmt.Print(str)
logs = append(logs, str)
......@@ -45,8 +45,8 @@ func main() {
}
}
func ImoprtWordsFromExcel(filePath string, db *gorm.DB) (sheetName string, count int) {
sheetName, rows := comm.GetExcel1stSheet(filePath)
func ImportWordsFromExcel(filePath string, db *gorm.DB) (sheetName string, count int) {
sheetName, rows := comm.GetExcelFirstSheet(filePath)
fmt.Printf("importing ... : [%s] \n", sheetName)
// fmt.Print(rows)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册