for record in sdc.records: try: my_j_list.append(jsonList(record)) record.value("data"] = my_j_list
except Exception as e: # Send record to error sdc.error.write(record, str(e))
sdc.output.write(record)
I tried fixing the indentation , but doesn’t seem to work. Your help would be much appreciated. Thanks.
Hi @tamilselg , i copied the code and pasted in a jython processor but it gave me no syntax errors and worked fine. can you please provide me with a sample of the input data and the error referred to which line of code ?
Thanks!
Hi @tamilselg , i copied the code and pasted in a jython processor but it gave me no syntax errors and worked fine. can you please provide me with a sample of the input data and the error referred to which line of code ?
Thanks!
@N_ali This is how my input looks like, it is failing at the last line which is sdc.output.write(record).
Thanks.
Hi @tamilselg , So the problem was that we are trying to access variable “record” outside the for loop.
That’s why it gave the error because this variable now is out of scope after the for loop.
we can make a slight change: we want the list to be written one time when all of the records are processed thus we can do the following (line 18,19) in the for loop after formatting the input object and now we can remove the last line that was causing the error.
except Exception as e: sdc.error.write(record, str(e))
Hope this helps.
Hi @tamilselg , So the problem was that we are trying to access variable “record” outside the for loop.
In the last line - that’s why it gave the error because this variable now is out of scope after the for loop.
we can make a slight change: we want the list to be written one time when all of the records are processed thus we can do the following (line 18,19) in the for loop after formatting the input object and now we can remove the last line that was causing the error.