@@ -75,6 +75,7 @@ type AreaCol struct {
|
|||||||
Col string `json:"col"`
|
Col string `json:"col"`
|
||||||
Field string `json:"field"`
|
Field string `json:"field"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
Split string `json:"split"`
|
||||||
Default string `json:"default"`
|
Default string `json:"default"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,12 +119,14 @@
|
|||||||
"col": "B",
|
"col": "B",
|
||||||
"field": "IndustryCode",
|
"field": "IndustryCode",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
"split": " ",
|
||||||
"default": "Please choose"
|
"default": "Please choose"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"col": "D",
|
"col": "D",
|
||||||
"field": "CountryCode",
|
"field": "CountryCode",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
"split": " ",
|
||||||
"default": "Please choose"
|
"default": "Please choose"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -145,6 +147,7 @@
|
|||||||
"col": "B",
|
"col": "B",
|
||||||
"field": "CountryCode",
|
"field": "CountryCode",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
"split": " ",
|
||||||
"default": "Please choose"
|
"default": "Please choose"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -165,6 +168,7 @@
|
|||||||
"col": "B",
|
"col": "B",
|
||||||
"field": "IndustryCode",
|
"field": "IndustryCode",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
"split": " ",
|
||||||
"default": "Please choose"
|
"default": "Please choose"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package loader
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.ecogood.org/andreas.schroepfer/excelConverter/pkg/ecalc"
|
"git.ecogood.org/andreas.schroepfer/excelConverter/pkg/ecalc"
|
||||||
"git.ecogood.org/andreas.schroepfer/excelConverter/pkg/set"
|
"git.ecogood.org/andreas.schroepfer/excelConverter/pkg/set"
|
||||||
@@ -46,11 +47,15 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
|
|||||||
axis := fmt.Sprintf("%s%d", c.Col, r)
|
axis := fmt.Sprintf("%s%d", c.Col, r)
|
||||||
cellValue, err := xFile.GetCellValue(
|
cellValue, err := xFile.GetCellValue(
|
||||||
xFile.GetSheetName(a.Sheet),
|
xFile.GetSheetName(a.Sheet),
|
||||||
axis,
|
axis)
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
|
if cellValue == c.Default {
|
||||||
|
continue
|
||||||
|
} else if c.Split != "" {
|
||||||
|
cellValue = strings.Split(cellValue, c.Split)[0]
|
||||||
|
}
|
||||||
err = set.Field(&sf, c.Field, cellValue)
|
err = set.Field(&sf, c.Field, cellValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs,
|
errs = append(errs,
|
||||||
@@ -58,6 +63,10 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
|
|||||||
a.Sheet, axis, err))
|
a.Sheet, axis, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (sf == ecalc.SupplyFraction{}) {
|
||||||
|
// do not add a empty struct
|
||||||
|
continue
|
||||||
|
}
|
||||||
eBalance.CompanyFacts.SupplyFractions =
|
eBalance.CompanyFacts.SupplyFractions =
|
||||||
append(
|
append(
|
||||||
eBalance.CompanyFacts.SupplyFractions,
|
eBalance.CompanyFacts.SupplyFractions,
|
||||||
@@ -67,14 +76,28 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
|
|||||||
for r := a.StartRow; r <= a.EndRow; r++ {
|
for r := a.StartRow; r <= a.EndRow; r++ {
|
||||||
ef := ecalc.EmployeesFraction{}
|
ef := ecalc.EmployeesFraction{}
|
||||||
for _, c := range a.Cols {
|
for _, c := range a.Cols {
|
||||||
|
axis := fmt.Sprintf("%s%d", c.Col, r)
|
||||||
cellValue, err := xFile.GetCellValue(
|
cellValue, err := xFile.GetCellValue(
|
||||||
xFile.GetSheetName(a.Sheet),
|
xFile.GetSheetName(a.Sheet),
|
||||||
fmt.Sprintf("%s%d", c.Col, r),
|
axis)
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
set.Field(&ef, c.Field, cellValue)
|
if cellValue == c.Default {
|
||||||
|
continue
|
||||||
|
} else if c.Split != "" {
|
||||||
|
cellValue = strings.Split(cellValue, c.Split)[0]
|
||||||
|
}
|
||||||
|
err = set.Field(&ef, c.Field, cellValue)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs,
|
||||||
|
fmt.Errorf("XLSXL.EmployeesFraction: Sheet %d, Cell %s: %w",
|
||||||
|
a.Sheet, axis, err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ef == ecalc.EmployeesFraction{}) {
|
||||||
|
// do not add a empty struct
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
eBalance.CompanyFacts.EmployeesFractions =
|
eBalance.CompanyFacts.EmployeesFractions =
|
||||||
append(
|
append(
|
||||||
@@ -85,14 +108,28 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
|
|||||||
for r := a.StartRow; r <= a.EndRow; r++ {
|
for r := a.StartRow; r <= a.EndRow; r++ {
|
||||||
is := ecalc.IndustrySector{}
|
is := ecalc.IndustrySector{}
|
||||||
for _, c := range a.Cols {
|
for _, c := range a.Cols {
|
||||||
|
axis := fmt.Sprintf("%s%d", c.Col, r)
|
||||||
cellValue, err := xFile.GetCellValue(
|
cellValue, err := xFile.GetCellValue(
|
||||||
xFile.GetSheetName(a.Sheet),
|
xFile.GetSheetName(a.Sheet),
|
||||||
fmt.Sprintf("%s%d", c.Col, r),
|
axis)
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
set.Field(&is, c.Field, cellValue)
|
if cellValue == c.Default {
|
||||||
|
continue
|
||||||
|
} else if c.Split != "" {
|
||||||
|
cellValue = strings.Split(cellValue, c.Split)[0]
|
||||||
|
}
|
||||||
|
err = set.Field(&is, c.Field, cellValue)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs,
|
||||||
|
fmt.Errorf("XLSXL.IndustrySector: Sheet %d, Cell %s: %w",
|
||||||
|
a.Sheet, axis, err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is == ecalc.IndustrySector{}) {
|
||||||
|
// do not add a empty struct
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
eBalance.CompanyFacts.IndustrySectors =
|
eBalance.CompanyFacts.IndustrySectors =
|
||||||
append(
|
append(
|
||||||
|
|||||||
Reference in New Issue
Block a user