Ask Your Question

Revision history [back]

getInputStream() returns a Java InputStream object, so you can read it line-by-line like this:

from java.io import InputStreamReader
from java.io import BufferedReader

for record in records:
  try:
    reader = BufferedReader(InputStreamReader(record.value['fileRef'].getInputStream()))
    try:
      while True:
        line = reader.readLine()
        if line is None:
          break
        log.debug("LINE: {}", line)

    finally:  
      reader.close()

    output.write(record)

  except Exception as e:
    error.write(record, str(e))