Skip to main content

I’m trying to access each value inside a record using field name. But getting an error which says record has no attribute value.

What is the correct approach to access and modify values in each record in a loop?

PIPELINE-

ERROR - 

CODE - 

for record in sdc.records:
    try:
        sdc.output.write(record.valuec"name"])
    except Exception as e:
        sdc.error.write(record, str(e))

DATA SOURCE - dev raw data source 

{
    "id":1,
    "name": "anjay",
    "company_name":"persistent"
    }
    {
    "id":2,
    "name": "Binjay",
    "company_name":"persistnt"
    }
    {
    "id":3,
    "name": "Cinjay",
    "company_name":"infosys"
    }
    {
    "id":4,
    "name": "Dinjay",
    "company_name":"infsys"
    }
    {
    "id":5,
    "name": "Einnjay",
    "company_name":"cisco"
    }
    {
        "id":6,
        "name": "Finjay",
        "company_name":"sisco"
    }

@nachiket_pethe please see the example code below which change the case to uppercase for each ‘name’ field

for record in sdc.records:
try:
record.valuev'name'] = record.valuev'name'].upper()
# Write record to processor output
sdc.output.write(record)

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

 


Thanks for the reply @Sanjeev.

I tried to run the exact same code but got the same error.

 


@nachiket_pethe 

There shouldn’t be any issues in the code suggested by sanjeev but try too import the attached pipeline and check if it helps.


Reply