增加提取指定列数据,并转换成map
This commit is contained in:
parent
73f4af74f9
commit
802c795914
@ -140,5 +140,35 @@ func (r *Read) ExtractAssignCol(colIndexList []int) (map[string][][]string, erro
|
||||
//
|
||||
// Date : 4:53 下午 2021/11/19
|
||||
func (r *Read) ExtractAssignColToMap(ruleTable map[int]string) (map[string][]map[string]string, error) {
|
||||
return nil, nil
|
||||
var (
|
||||
allData map[string][][]string
|
||||
err error
|
||||
formatResult map[string][]map[string]string
|
||||
)
|
||||
formatResult = make(map[string][]map[string]string)
|
||||
if allData, err = r.GetAllData(); nil != err {
|
||||
return nil, err
|
||||
}
|
||||
for sheetName, sheetData := range allData {
|
||||
formatResult[sheetName] = make([]map[string]string, 0)
|
||||
for _, lineData := range sheetData {
|
||||
tmpResult := make(map[string]string)
|
||||
for idx, colData := range lineData {
|
||||
colName, exist := ruleTable[idx]
|
||||
if !exist {
|
||||
// 当前字段不需要提取
|
||||
continue
|
||||
}
|
||||
tmpResult[colName] = colData
|
||||
}
|
||||
for _, colName := range ruleTable {
|
||||
if _, exist := tmpResult[colName]; !exist {
|
||||
tmpResult[colName] = ""
|
||||
}
|
||||
}
|
||||
formatResult[sheetName] = append(formatResult[sheetName], tmpResult)
|
||||
}
|
||||
}
|
||||
// 格式化数据
|
||||
return formatResult, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user