diff --git a/csv.go b/csv.go index 7448ada..ab14ef3 100644 --- a/csv.go +++ b/csv.go @@ -1,6 +1,5 @@ package csv -// TODO(tbshill): Move this outside of gocdrm into a public gopackage // TODO(tbshill): Encoding multiline elements import ( diff --git a/gencsv/main.go b/gencsv/main.go index 4f6929a..9fe3cc4 100644 --- a/gencsv/main.go +++ b/gencsv/main.go @@ -50,7 +50,8 @@ func New%s(filename string, row int, data %s) *%s { } } -func Load%s(filenames []string, parallelism int, dl, nl string) (chan *%s, chan error){ + +func Load%s(filenames []string, parallelism int, dl, nl string, onFileFinish func(filename string, totalRows int)) (chan *%s, chan error){ recordChan, errChan := make(chan *%s), make(chan error) go func(){ defer close(recordChan) @@ -78,13 +79,14 @@ func Load%s(filenames []string, parallelism int, dl, nl string) (chan *%s, chan return } - defer func(){ + rowNum := 0 + defer func(rowNum int){ if err := f.Close(); err != nil{ errChan <- err } - }() + onFileFinish(filename, rowNum) + }(rowNum) - rowNum := 0 decoder := csv.NewDecoder(dl, nl, f) %s for decoder.Scan() { diff --git a/go.mod b/go.mod index c4c42d8..32f5f8f 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module github.com/tbshill/csv go 1.13 - -require github.com/tbshillcdr/gocdrm v1.0.3 diff --git a/go.sum b/go.sum index bb1c6e5..e69de29 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +0,0 @@ -github.com/agatan/bktree v0.0.0-20170513134333-739c0743f255/go.mod h1:L5xUMDqprPOuD4rCv+HBtHCvDzs4mWOJeVDcOawbFLc= -github.com/creasty/go-levenshtein v0.0.0-20161128082938-38ce641d5030/go.mod h1:lOCZAIOJdOr4nhnfYZxyv6nN4NNG848ubmh4SpwFyI8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.13.2/go.mod h1:LzqnAvaD5TWeNBsZpfKxSYn1MbjWwOsCIAFFJbpIsK8= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/simpleforce/simpleforce v0.0.0-20210518005708-245ee39ac3ec/go.mod h1:abS7k7nPhcNtzsAsfzOedGmI7yU0PDzQVwlHJZwGgOs= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/tbshill/csv v0.0.0-20210811034324-39629ad9b789/go.mod h1:r3GLXBLJKng7p/d03EQDg80TXdDqIMc/MFRfaAxoFFY= -github.com/tbshillcdr/gocdrm v1.0.3 h1:B6T7fnh64Ydmw3XkWLwncEd8mjr6mE2HE6jBtERk3tI= -github.com/tbshillcdr/gocdrm v1.0.3/go.mod h1:NQ6MUPJ1lxu3oY/ZEiu4L5QPmGdt2UqRkI3rzNkI30M= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=