Forum Stats

  • 3,726,735 Users
  • 2,245,248 Discussions
  • 7,852,382 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Jython code understand

Robeen
Robeen Member Posts: 1,990 Silver Badge

Hi,


I would like to get help understand this piece of jython code. This is used to convert date


from datetime import date,datetime,timedelta

for record in sdc.records: <<------ is sdc an object? From which class? Is records a variable?

 try:

  for (field,vals) in record.value.iteritems(): << is record an object? what is value/iteritems?

    sdc.log.info("{}",vals)

    sdc.log.info("{}",type(vals))

    if 'Date' in str(type(vals)):

     sdc.log.info("Converted: {}", date.fromtimestamp(vals.getTime()+14400 ))

     sdc.log.info("After: {}", date.fromtimestamp(vals.getTime()+14400 ))

     record[field] = date.fromtimestamp(vals.getTime()+14400 )

  sdc.output.write(record)


 except Exception as e:

  # Send record to error

  sdc.error.write(record, str(e))


Thanks,


Joe

Sign In or Register to comment.