Slide 28
Slide 28 text
45&1࣮ͦͷ
JNQPSUʹҎԼͷߦΛՃ͠·͢
"golang.org/x/text/encoding/japanese
"
"golang.org/x/text/transform
"
ઌఔͷʮ50%0ʯΛҎԼʹஔ͖͑·͢
records, err := csv.NewReader(transform.NewReader(bytes.NewReader(body), japanese.ShiftJIS.NewDecoder())).ReadAll(
)
if err != nil
{
return nil, fmt.Errorf("σʔλͷղੳʹࣦഊ͠·ͨ͠: %w", err
)
}
var entries []Entr
y
for i, row := range records
{
if i == 0
{
continue // ϔομʔߦΛεΩοϓ
}
if len(row) != 2
{
return nil, fmt.Errorf("ఆ֎ͷσʔλʹૺ۰͠·ͨ͠: ߦ %d = %v", i+1, row
)
}
entries = append(entries, Entry{YMD: row[0], Name: row[1]}
)
}
return entries, nil