![](/img/trans.png)
[英]How to get the characters following the keyword from a string (python)?
[英]How to get tablenames from the following in python
我正在将大型查询客户端与python一起使用,以从大型查询中检索表名称。
result = client._get_all_tables(datasetID,cache=False)
print result
for x in result:
结果如下
{u'totalItems': 7, u'tables': [{u'kind': u'bigquery#table', u'type': u'TABLE', u'id': u'publicdata:samples.github_nested', u'tableReference': {u'projectId': u'publicdata', u'tableId': u'github_nested', u'datasetId': u'samples'}}, {u'kind': u'bigquery#table', u'type': u'TABLE', u'id': u'publicdata:samples.github_timeline', u'tableReference': {u'projectId': u'publicdata', u'tableId': u'github_timeline', u'datasetId': u'samples'}}, {u'kind': u'bigquery#table', u'type': u'TABLE', u'id': u'publicdata:samples.gsod', u'tableReference': {u'projectId': u'publicdata', u'tableId': u'gsod', u'datasetId': u'samples'}}, {u'kind': u'bigquery#table', u'type': u'TABLE', u'id': u'publicdata:samples.natality', u'tableReference': {u'projectId': u'publicdata', u'tableId': u'natality', u'datasetId': u'samples'}}, {u'kind': u'bigquery#table', u'type': u'TABLE', u'id': u'publicdata:samples.shakespeare', u'tableReference': {u'projectId': u'publicdata', u'tableId': u'shakespeare', u'datasetId': u'samples'}}, {u'kind': u'bigquery#table', u'type': u'TABLE', u'id': u'publicdata:samples.trigrams', u'tableReference': {u'projectId': u'publicdata', u'tableId': u'trigrams', u'datasetId': u'samples'}}, {u'kind': u'bigquery#table', u'type': u'TABLE', u'id': u'publicdata:samples.wikipedia', u'tableReference': {u'projectId': u'publicdata', u'tableId': u'wikipedia', u'datasetId': u'samples'}}], u'kind': u'bigquery#tableList', u'etag': u'"hnk59tKBkX8cdlePZ8VtzgVzuO4/2P51RdhDvk7tUvXpY_uairNEWDE"'}
如何从上面的字典列表中获取表名?
预期产量:
github_nested
github_timeline
gsod
natality
shakespeare
trigrams
wikipedia
我已经按照以下方式做了,
tablesWithDetails = result["tables"]
print tablesWithDetails
for inditable in tablesWithDetails:
tables.append(inditable["id"])
return tables
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.