Filing two iterations with one enumerator

I am very new to developing frameworks, functional programs, and Iteratee I / O, so maybe my question is very off topic or even stupid.

I would like to download large text files as a stream to a third party and at the same time extract metadata about this file (based on its contents to simplify the mentioned csv file).

I already wrote two analyzers of the working fluid: Iteratee[Array[Byte], B]one that contains the recording logic and Iteratee[Array[Byte], MetaData]one that contains the metadata extraction logic. Could you tell me how to combine these two parsers to handle recording and retrieving content at the same time.

+5
source share
1 answer

, it1 it1, , "zipped" iteratee (zippedIt ), , , , it1 it2. . Iteratee zip.

:

import play.api.libs.iteratee.{Enumerator, Iteratee, Enumeratee}

val e = Enumerator("1", "2", "3")
val it1 = Iteratee.foreach[String](v => println("1: " + v))
val it2 = Iteratee.foreach[String](v => println("2: " + v))
val zippedIt = Enumeratee.zip(it1, it2)
e(zippedIt)

:

1: 1
2: 1
1: 2
2: 2
1: 3
2: 3
+4

All Articles