~mendelmaleh/pfin

ref: 1f051309601a4da2841fade1e72cb120bccab370 pfin/parser/capitalone/parser.go -rw-r--r-- 377 bytes
1f051309Mendel E Add license 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package capitalone

import (
	"git.sr.ht/~mendelmaleh/pfin"
	"github.com/jszwec/csvutil"
)

func Parse(data []byte, txns *[]pfin.Transaction) error {
	var raw []RawTransaction
	if err := csvutil.Unmarshal(data, &raw); err != nil {
		return err
	}

	// reverse order so it's chronological
	for i := len(raw) - 1; i != -1; i-- {
		*txns = append(*txns, raw[i])
	}

	return nil
}