<commit_before>// excel操作类
// create by gloomy 2017-4-18 09:14:26
package gutil

import (
	"errors"
	"fmt"
	"github.com/tealeg/xlsx"
)

// excel数据获取
// create by gloomy 2017-4-18 12:00:34
// sheet名称 数据内容 错误对象
func ReadExcel(excelFilePath string) (*map[string][]string, error) {
	xlFile, err := xlsx.OpenFile(excelFilePath)
	if err != nil {
		return nil, err
	}
	var (
		excelData   map[string][]string
		columnValue string
	)
	for _, sheet := range xlFile.Sheets {
		for _, row := range sheet.Rows {
			for _, cell := range row.Cells {
				columnValue, err = cell.String()
				if err != nil {
					fmt.Println("ReadExcel ", err.Error())
					continue
				}
				excelData[sheet.Name] = append(excelData[sheet.Name], columnValue)
			}
		}
	}
	return &excelData, nil
}

// excel保存
// create by gloomy 2017-4-18 09:44:39
func ExcelSave(saveContent *map[string][]string, saveFilePath string) error {
	var (
		file  *xlsx.File
		sheet *xlsx.Sheet
		row   *xlsx.Row
		cell  *xlsx.Cell
		err   error
	)
	if len(*saveContent) == 0 {
		return errors.New("send data length is 0!")
	}
	file = xlsx.NewFile()
	for sheetName, values := range *saveContent {
		sheet, err = file.AddSheet(sheetName)
		if err != nil {
			return err
		}
		if len(values) != 0 {
			row = sheet.AddRow()
			for _, columnValue := range values {
				cell = row.AddCell()
				cell.Value = columnValue
			}
		}
	}
	return file.Save(saveFilePath)
}
<commit_msg>修正赋值BUG<commit_after>// excel操作类
// create by gloomy 2017-4-18 09:14:26
package gutil

import (
	"errors"
	"fmt"
	"github.com/tealeg/xlsx"
)

// excel数据获取
// create by gloomy 2017-4-18 12:00:34
// sheet名称 数据内容 错误对象
func ReadExcel(excelFilePath string) (*map[string][]string, error) {
	xlFile, err := xlsx.OpenFile(excelFilePath)
	if err != nil {
		return nil, err
	}
	var (
		excelData   map[string][]string
		columnValue string
		ok          bool
	)
	for _, sheet := range xlFile.Sheets {
		for _, row := range sheet.Rows {
			for _, cell := range row.Cells {
				columnValue, err = cell.String()
				if err != nil {
					fmt.Println("ReadExcel ", err.Error())
					continue
				}
				_, ok = excelData[sheet.Name]
				if !ok {
					excelData[sheet.Name] = []string{columnValue}
					continue
				}
				excelData[sheet.Name] = append(excelData[sheet.Name], columnValue)
			}
		}
	}
	return &excelData, nil
}

// excel保存
// create by gloomy 2017-4-18 09:44:39
func ExcelSave(saveContent *map[string][]string, saveFilePath string) error {
	var (
		file  *xlsx.File
		sheet *xlsx.Sheet
		row   *xlsx.Row
		cell  *xlsx.Cell
		err   error
	)
	if len(*saveContent) == 0 {
		return errors.New("send data length is 0!")
	}
	file = xlsx.NewFile()
	for sheetName, values := range *saveContent {
		sheet, err = file.AddSheet(sheetName)
		if err != nil {
			return err
		}
		if len(values) != 0 {
			row = sheet.AddRow()
			for _, columnValue := range values {
				cell = row.AddCell()
				cell.Value = columnValue
			}
		}
	}
	return file.Save(saveFilePath)
}

{'fraction_non_alphanumeric': 0.1353991242842708, 'fraction_numerical': 0.028292354328056584, 'mean_word_length': 3.0026954177897576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6905530', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1142, 'n_words': 269}