I am relatively new to Akka Streams and Alpakka and would like some advice on how to handle a problem I’m facing -
I have an object that contains a CSV String and some other metadata. I’d like to pass the String in this Java object through the Alpakka CSVParsing flow and then use the output CSV Map to populate other fields in the object. This is what the Flow currently looks like:
Flow.of(MyObject.class) .map(MyObject::getCSVString) .via(CsvParsing.lineScanner(.....)) .via(CsvToMap.toMapAsStrings(.....)) .via(....) // other operations for which I'd like to keep the metadata in the original MyObject element
The problem is that once I map my object to the string csv files, I lose the other data in MyObject object. Is there a way to keep the data in the object while passing the string in it through the CsvParsing flow?
I’ve looked into SourceWithContext and FlowWithContext which seem helpful but I’m not fully sure how to use it in this situation.
Please let me know if you have any tips/advice. Thank you!