python - 通过 Matillion AWS 在 Jython 中使用 org.python.core.PyList
问题描述
我在 Matillion ETL 中为 Redshift 运行 Python 脚本组件。该组件使用 Jython,代码如下。由于对象转换错误,我在 context.updateGridVariable 行上收到错误。
我想知道如何实例化一个 org.python.core.PyList 对象,以便我可以填充它,而不是我得到的 java.lang.String。
输出
[u's3://bucket-landingzone/inbox/dt_employees_20180614.csv'] java.lang.ClassCastException: java.lang.ClassCastException: java.lang.String 无法在行号处转换为 org.python.core.PyList 26
代码
import boto3
import json
s3 = boto3.resource('s3')
bucket = "bucket-landingzone"
name = "inbox/dt_employee_20180615"
file_list = []
manifest_object = s3.Object(bucket,name)
file_content = manifest_object.get()['Body'].read().decode('utf-8')
json_content = json.loads(file_content)
for entry in json_content['entries']:
for attribute, value in entry.iteritems():
if attribute == 'url':
file_list.append(value)
print(file_list)
context.updateGridVariable('manifest_entries', file_list)
print(context.getGridVariable('manifest_entries'))
解决方案
推荐阅读
- xaml - XAML 绑定数据
- java - 谷歌云语音到文本 API 401 错误 java
- python - 打破外部 For 循环
- html - 角度 src 图像的延迟加载
- c# - 如何以度数获得对象旋转?统一
- mongodb - MongoDB 中的 UpdateMany 使用 $inc 运行两次
- node.js - 应用程序级别的 Kubernetes 证书?
- r - 如何使用 inst/extdata 中的文件?R 包检查防止在 R 3.6 中使用 system.file()
- javascript - 获取后“TypeError:无法读取未定义的属性'forEach'”
- python - 当我知道密钥存在时如何处理 Python (JSON) 密钥错误?