93 lines
2.6 KiB
Go
93 lines
2.6 KiB
Go
package main
|
||
|
||
import (
|
||
"fmt"
|
||
"strconv"
|
||
|
||
"github.com/360EntSecGroup-Skylar/excelize/v2"
|
||
)
|
||
|
||
func main() {
|
||
langHashMap := make(map[string]string)
|
||
populateLanguageHash(langHashMap)
|
||
|
||
convertTurkeyToEngLabel("credit-card-transactions/Domestic-and-international-Usage.xlsx",
|
||
"Sheet1", langHashMap)
|
||
|
||
// exchangeHandler := initExhangeData()
|
||
// println(exchangeHandler["Some_key"].usd)
|
||
}
|
||
|
||
func convertTurkeyToEngLabel(fileName string, sheetName string, langHash map[string]string) {
|
||
//create new file for label conversion
|
||
fileLabelConversion := excelize.NewFile()
|
||
index := fileLabelConversion.NewSheet(sheetName)
|
||
|
||
//read from base xls file
|
||
file, err := excelize.OpenFile(fileName)
|
||
if err != nil {
|
||
fmt.Println(err)
|
||
return
|
||
}
|
||
|
||
// Get all the rows in base file
|
||
rows, err := file.GetRows(sheetName)
|
||
for rowIndex, row := range rows {
|
||
convertColumnItemsTurkeyToEng(row, langHash)
|
||
|
||
cellName := "A" + strconv.Itoa(rowIndex+1)
|
||
fileLabelConversion.SetSheetRow(sheetName, cellName, &row)
|
||
}
|
||
|
||
// Set active sheet of the workbook.
|
||
fileLabelConversion.SetActiveSheet(index)
|
||
// Save xlsx file by the given path.
|
||
if err := fileLabelConversion.SaveAs("credit-card-transactions/Domestic-and-international-Usage-eng.xlsx"); err != nil {
|
||
fmt.Println(err)
|
||
}
|
||
}
|
||
|
||
func convertColumnItemsTurkeyToEng(row []string, langHash map[string]string) {
|
||
for i, item := range row {
|
||
if value, ok := langHash[item]; ok {
|
||
row[i] = value
|
||
}
|
||
}
|
||
}
|
||
|
||
func populateLanguageHash(langHash map[string]string) {
|
||
langHash["Dönem"] = "period"
|
||
langHash["OCAK"] = "january"
|
||
langHash["ŞUBAT"] = "february"
|
||
langHash["MART"] = "March"
|
||
langHash["1. DÖNEM"] = "1st Quarter"
|
||
langHash["NISAN"] = "April"
|
||
langHash["MAYIS"] = "May"
|
||
langHash["HAZIRAN"] = "June"
|
||
langHash["2. DÖNEM"] = "2nd Quarter"
|
||
langHash["TEMMUZ"] = "July"
|
||
langHash["AĞUSTOS"] = "August"
|
||
langHash["EYLÜL"] = "Sepember"
|
||
langHash["3. DÖNEM"] = "3rd Quarter"
|
||
langHash["EKIM"] = "October"
|
||
langHash["KASIM"] = "November"
|
||
langHash["ARALIK"] = "December"
|
||
langHash["4. DÖNEM"] = "4th Quarter"
|
||
langHash["2020 YILI"] = "2020 year"
|
||
langHash["2019 YILI"] = "2019 year"
|
||
langHash["2018 YILI"] = "2018 year"
|
||
langHash["2017 YILI"] = "2017 year"
|
||
langHash["2016 YILI"] = "2016 year"
|
||
langHash["2015 YILI"] = "2015 year"
|
||
langHash["2014 YILI"] = "2014 year"
|
||
langHash["2013 YILI"] = "2013 year"
|
||
langHash["2012 YILI"] = "2012 year"
|
||
langHash["2011 YILI"] = "2011 year"
|
||
langHash["İşlem Adedi"] = "Number of transaction over period"
|
||
langHash["İşlem Tutarı (Milyon TL)"] = "Volumn of transactions (Million TL)"
|
||
langHash["Alışveriş"] = "Purchase"
|
||
langHash["Nakit Çekme"] = "Cash"
|
||
langHash["Toplam"] = "Total"
|
||
// langHash[""] = ""
|
||
}
|