I am using Alpakka and Akka to process a CSV file. Since I have a bunch of CSV files that have to be added to the same stream, I would like to add a field that contains information from the file name or request. Currently I have something like this:
val source = FileIO.fromPath(Paths.get("10002070.csv"))
.via(CsvParsing.lineScanner())
Which streams a Sequence of Lists (lines) of ByteStrings (fields). The goal would be something like:
val filename = "10002070.csv"
val source = FileIO.fromPath(Path.get(filename))
.via(CsvParsing.lineScanner())
.via(AddCSVFieldHere(filename))
Creating a structure similar to:
10002070.csv,max,estimated,12,1,0
Where the filename is a field non-existent in the original source.
I thing it does not look very pretty to inject values mid-stream, plus eventually I would like to determine the filenames passed to the parsing in a stream stage that reads a directory.
What is the correct/canonical way to pass values through stream stages for later re-use?