I want to calculate the group total count and parse the group in the same Flow.run .
Currently it looks inefficient as calling flow twice.
def parse(config) do
mapping = config["mapping"]
flow = config
|> config_parser_and_return_csv_data
|> String.split("\n")
|> CSVParser.parse_stream
|> Stream.drop(config["params"]["rows"] |> skip_rows)
|> Stream.filter(&data_row?(&1))
|> Flow.from_enumerable()
|> Flow.filter(&isValidRow?(&1, mapping))
|> Flow.partition(key: &increment_id(&1, mapping))
|> Flow.group_by(&Enum.at(&1, increment_id_position(mapping)))
# require IEx
# IEx.pry
config = config |> Map.put("order_count", flow |> Enum.count)
flow
|> Flow.map(&parse_data_columns(&1, config))
|> Flow.run
end