我正在运行一个googleanalytics API脚本,我想用它来导出会话数据。在
现在我正在打印数据:
def get_segment_sessions(service, profile_id, segment_id):
return service.data().ga().get(
ids='ga:' + profile_id,
segment='gaid::' + segment_id,
start_date='7daysAgo',
end_date='yesterday',
metrics='ga:sessions',
dimensions='ga:date').execute()
def print_results(results):
# Print data nicely for the user.
if results:
# print 'View (Profile): %s' % results.get('profileInfo').get('profileName')
# print 'Date: %s' % results.get('date') + ' Total Sessions: %s' % results.get('rows')[0][0]
output = []
for header in results.get('columnHeaders'):
output.append('%30s' % header.get('name'))
print(''.join(output))
if results.get('rows', []):
for row in results.get('rows'):
output = []
for cell in row:
output.append('%30s' % cell)
print(''.join(output))
看起来像:
^{pr2}$如何将其导出为JSON格式以在S3/Redshift中使用?在
目前没有回答
相关问题 更多 >
编程相关推荐