Last active
August 6, 2022 03:31
-
-
Save dele454/b31c2eca9df45a36034340a9a94ace94 to your computer and use it in GitHub Desktop.
Part 1 - CSV Transformation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cmd | |
import ( | |
"sync" | |
"github.com/dele454/medium/csv-transform-to-html/internal/parser" | |
"github.com/dele454/medium/csv-transform-to-html/internal/report" | |
"github.com/dele454/medium/csv-transform-to-html/internal/transform" | |
) | |
func Process(file string) { | |
// create a reporter | |
reporter := report.NewTransformationReporter() | |
// create a new parser | |
parser := parser.NewCSVParser(file, reporter) | |
// create waitgroup | |
wg := new(sync.WaitGroup) | |
wg.Add(2) | |
// channels for pipeline | |
record := make(chan []string) | |
done := make(chan bool) | |
// transformer | |
go transform.NewHTMLTransformer(reporter). | |
ProcessRecord(wg, record, done) | |
// read the csv | |
go parser.Read(wg, record, done) | |
// wait for all go routines to finish | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment