Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi!

The exception is caused by the nested recursion that occurs by adding the 'child' dictionary to the record and then manipulating its value while iterating over the record key-value pairs. (Hard-coded value of 2 works because it's a single element/item and not a dictionary.)

Replace your code with the following and it will work:

for record in records:
  try:
    key_value_pairs = {}
    for (k,v) in record.value.items():
      key_value_pairs[k] = v

    record.value['child'] = key_value_pairs

    # Write record to processor output
    output.write(record)
  except Exception as e:
    # Send record to error
    error.write(record, str(e))

Cheers, Dash

Hi!

The exception is caused by the nested recursion that occurs by adding the 'child' dictionary to the record and then manipulating its value while iterating over the record key-value pairs. (Hard-coded value of 2 works because it's a single element/item and not a dictionary.)

Replace your code with the following and it will work:

for record in records:
  try:
    key_value_pairs = {}
    for (k,v) in record.value.items():
      key_value_pairs[k] = v

    record.value['child'] = key_value_pairs

    # Write record to processor output
    output.write(record)
  except Exception as e:
    # Send record to error
    error.write(record, str(e))

image description

Cheers, Dash

Hi!

The exception is caused by the nested recursion that occurs by adding the 'child' dictionary to the record and then manipulating its value while iterating over the record key-value pairs. (Hard-coded value of 2 works because it's a single element/item and not a dictionary.)

Replace your code with the following and it will work:

for record in records:
  try:
    key_value_pairs = {}
    for (k,v) in record.value.items():
      key_value_pairs[k] = v
      #optionally delete root entry
      del record.value[k]

    record.value['child'] = key_value_pairs

    # Write record to processor output
    output.write(record)
  except Exception as e:
    # Send record to error
    error.write(record, str(e))

image description

Cheers, Dash

Hi!

The exception is caused by the nested recursion that occurs by adding the 'child' dictionary to the record and then manipulating its value while iterating over the record key-value pairs. (Hard-coded value of 2 works because it's a single element/item and not a dictionary.)

Replace your code with the following and it will work:

for record in records:
  try:
    key_value_pairs = {}
    for (k,v) in record.value.items():
      key_value_pairs[k] = v
      #optionally delete root entry
      del #del record.value[k]

    record.value['child'] = key_value_pairs

    # Write record to processor output
    output.write(record)
  except Exception as e:
    # Send record to error
    error.write(record, str(e))

image description

Cheers, Dash