【发布时间】:2019-08-25 02:07:02
【问题描述】:
我正在使用 python 从 Linkedin AD API 获取数据。
我将数据作为 json 字符串获取。
如何将此 json 插入带有变体列的 Snowfalke 表中?
除了变体,“元素”内的字段也可以作为正常插入。
我是 json 和 python 的新手,所以很想在这方面得到一些帮助。
这是我得到的示例 json 字符串。
{
"elements": [
{
"dateRange": {
"start": {
"month": 3,
"year": 2019,
"day": 3
},
"end": {
"month": 3,
"year": 2019,
"day": 3
}
},
"clicks": 11,
"impressions": 2453,
"pivotValues": [
"urn:li:sponsoredCampaign:1234567"
]
},
{
"dateRange": {
"start": {
"month": 3,
"year": 2019,
"day": 4
},
"end": {
"month": 3,
"year": 2019,
"day": 4
}
},
"clicks": 4,
"impressions": 816,
"pivotValues": [
"urn:li:sponsoredCampaign:1234567"
]
},
{
"dateRange": {
"start": {
"month": 3,
"year": 2019,
"day": 7
},
"end": {
"month": 3,
"year": 2019,
"day": 7
}
},
"clicks": 1,
"impressions": 629,
"pivotValues": [
"urn:li:sponsoredCampaign:1234565"
]
},
{
"dateRange": {
"start": {
"month": 3,
"year": 2019,
"day": 21
},
"end": {
"month": 3,
"year": 2019,
"day": 21
}
},
"clicks": 3,
"impressions": 154,
"pivotValues": [
"urn:li:sponsoredCampaign:1323516"
]
}
],
"paging": {
"count": 10,
"start": 0,
"links": []
}
}
【问题讨论】:
-
您可能应该更具体。整个 JSON 是一个字符串吗?这是不太可能的。提供字符串或 JSON 的示例,并更具体地说明您想要什么 - 歧义只会导致您的问题被忽略。
-
感谢您的建议。我已经更新了问题。
标签: python python-3.x api linkedin-api snowflake-cloud-data-platform