OnRecordException when using split on jython evaluator

asked 2019-07-19 11:26:01 -0600

Buzzlight gravatar image

updated 2019-07-19 17:02:14 -0600

I am seeing a OnRecordException when I use split method on parsing the input file but it works on splitlines method. Since some of the input is more than one line I need to use split. I need help on finding a solution as I can see the data as map on preview method on using both methods but not working on split method. Error: com.streamsets.pipeline.api.base.OnRecordErrorException: SCRIPTING_04 - Script sent record to error:

Sample Code:

Sample input: "KEY/VAL1/VAL2/VAL3/VAL4/VAL5/VAL6 /VAL7//"

text = record.value['report']
rows = text.split('//')
for r in rows:
    fields = r.split('/', 1)
    if len(fields) ==2:
      key=fields[0]
      item[key] = fields[1]
 record.value = item
 output.write(record)

On the next jython evluator when I try to access the key I am seeing the above error. I also verified whether the code is in between try exception block. As I said it works with splitlines method.

edit retag flag offensive close merge delete