开发者

Does anyone know the attributes of a Google Analytics DataPoint object?

I'm currently trying to pull GA data using Python; I've gotten as far as retrieving a list of DataPoin开发者_JAVA百科t objects, and I can see inside them using .list, but I can't access their values directly.

For example, I've got this

>>> print(data.list)
[[[u'Android Browser'], [80]], [[u'Chrome'], [127]], [[u'Firefox'], [78]], [[u'Internet Explorer'], [564]], [[u'Mozilla'], [2]], [[u'Mozilla Compatible Agent'], [7]], [[u'Opera'], [2]], [[u'Safari'], [175]]]

But when I try to do this

data[0]

I get this

<googleanalytics.data.DataPoint object at 0x00D06DB0>

which is just a black box to me; I can't get inside it to split up the content for actual use.

I got one lucky guess: the first of the pair of attributes is called 'title'. "data[0].title" gives me this

'ga:browser=Android Browser'

which I can use. I just need that second attribute name. Does anybody know it?

Thanks a lot!


There's a page at the documentation explaining each field.

http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDataFeed.html#dataResponse


I figured it out: I was able to crack open the object using the inspect module, and that told me that the attributes were accessible using the same names I used in the query. Convenient language, this Python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜