How to import GA Data using Python

1,518 views
Skip to first unread message

Sa

unread,
Jun 1, 2010, 11:35:14 AM6/1/10
to google-analytics-api - GA Data Export API
Hi,

I'm new to Python & tried to using "gdata-python-client". But when I'm
running this code "import gdata.analytics.client
import gdata.sample_util", I'm getting this error "Traceback (most
recent call last):
File "<pyshell#0>", line 1, in <module>
import gdata.analytics.client
ImportError: No module named gdata.analytics.client".

I'm not a developer or have any technical knowledge. I want to use
Python as I want to fetch data directly into Python then analyze it.
Getting data into excel, then putting it into some analytics package
to analyze is very hectic.

I'll be grateful if anybody can help me in my task. I'm learning
Python & can do basic programming.

Regards,
Arijit

Sa

unread,
Jun 1, 2010, 3:09:40 PM6/1/10
to google-analytics-api - GA Data Export API
Hi,

There;s some problem in importing the gdata module. Can anybody tell
me what can be the problem.

Regards,
Arijit

Nick

unread,
Jun 3, 2010, 6:24:55 PM6/3/10
to google-analytics-api - GA Data Export API
Hi,

A couple things. There is no way to import data into Google Analytics.
We do have a client library for our Data Export API.

After you download the Python library you'll need to ensure it's been
installed and can be reference from the python interpreter.

What happens when you type import gdata?

If you get an error you'll need to read this doc:
http://code.google.com/p/gdata-python-client/wiki/GettingStarted

-Nick

Sa

unread,
Jun 4, 2010, 12:08:08 PM6/4/10
to google-analytics-api - GA Data Export API
Hi Nick,

Thank you for your reply. I thought my question is too silly that's
why nobody is replying. My Python has installed properly.I've
installed Python31. I can even run code in command prompt.All sorts of
command I can run. But my problem is I cannot able to import
gdata-2.0.10.

In the instruction it's saying run ./setup.py install (I've admin
right). Now where to run this code (in GUI,Command Prompt,or any other
place). This is because wherever I'm running this code either it's
showing "not recognized as internal or external command operable prog
or batch file" (when running in cmd) or "no module named gdata
exits" (when running in GUI as import gdata). Once I can import gdata
into python, hope life become simpler.

I'll be grateful if Nick or somebody else can help me in this.

Regards,
Arijit

Nick

unread,
Jun 4, 2010, 1:25:39 PM6/4/10
to google-analytics-api - GA Data Export API
The Google Data python client library only works on 2.4-2.6.

There is an open bug to fix it for python 3:
http://code.google.com/p/gdata-python-client/issues/detail?id=229&q=3.0

Also here's a doc on how to install the library:
http://code.google.com/apis/gdata/articles/python_client_lib.html
Once you can import gdata, you should also be able to import the
analytics specific libraries.

-Nick

Sa

unread,
Jun 4, 2010, 3:04:14 PM6/4/10
to google-analytics-api - GA Data Export API
Hi Nick,

Thank you for your reply & the references. I've read the reference on
how to install gdata. But the problem is it say run "./setup.py
install". But when I'm running this code, it showing error
(SyntaxError: invalid syntax). I don't know what is the mistake I'm
making.

I'll be grateful if you can help me to figure out this puzzle.

Regards,
Arijit

Dave Hudgins

unread,
Dec 17, 2012, 4:59:17 PM12/17/12
to google-analytics...@googlegroups.com
This is an old topic, and I certainly hope you have gotten an answer by now, but in case you or someone else reaches this from a search like I just did, then I would recommend doing the following:

On windows download and install:
Console2
PyCmd

You can map Console2 to use PyCmd as its command interpreter, and then you simple can run the "setup.py install" from the location the file is in.  This would be done by launching Console2 and then navigating to it.

Omar Cervantes

unread,
Apr 4, 2013, 6:39:25 PM4/4/13
to google-analytics...@googlegroups.com
I am actually trying to do the same thing. I am trying to get data on business and customer reviews. I already got my API key. I am assuming I have to the steps below next?  

Aaron Toledo

unread,
Apr 5, 2013, 1:54:16 AM4/5/13
to google-analytics...@googlegroups.com
I migrated away from the gdata library when I switched from v2 to v3 of the API, so I'm not sure if it's updated. I use this library, and it's pretty straight forward: https://code.google.com/p/google-api-python-client/source/checkout
Reply all
Reply to author
Forward
0 new messages