When you feed the data in python, the type must already be the type it
expects.
That is, if you want to feed a datetime object, you need the python object
to be of type datetime in advance (and not to put the tuple of parameters
that the datatime constructor is expecting).

Take a look at the test of the API for an example:
http://code.google.com/codesearch#OjTIN7pvng8/trunk/gviz_api_test.py&package:http://google-visualization-python%5C.googlecode%5C.com&l=482

  Viz Kid

On Tue, Feb 28, 2012 at 6:56 PM, ViPeRaY <[email protected]> wrote:

> Hello All,
>
> I am having this weird issue where I cannot just get around. I need to
> convert massive amount of data to json to plot on timeline charts. I
> found givz_api (http://code.google.com/apis/chart/interactive/docs/dev/
> gviz_api_lib.html#populatedata) which could do that for me. I have
> tested it with strings and numbers and it works great. However it wont
> work with datetime. Here is my code:
>
> ----------------------------------------------------------------------------------------------
> #!/usr/bin/env python2.6
> # -*- coding: UTF-8 -*-
>
> import cgi, cgitb, gviz_api
>
> cgitb.enable()
>
> def main():
>
>        description = {"data_time": ('datetime', 'Date/Time'),
>                                        "open": ('number', 'Open'),
>                                        "active": ('number', 'Active'),
>                                        "ua": ('number', 'U/A'),
>                                        "fr": ('number', 'F/R'),
>                                        "fourhr": ("number", "4hr+")}
>
>        data = [{'data_time': (2012, 02, 14, 15, 00, 00),
>                                'open': 156,
>                                'active': 128,
>                                'ua': 16,
>                                'fr': 25,
>                                'fourhr': 32}]
>
>
>        data_table = gviz_api.DataTable(description)
>        data_table.LoadData(data)
>        print "Content-type: text/plain"
>        print
>        print data_table.ToJSonResponse(columns_order=("data_time", "open",
> "active", "ua", "fr", "fourhr"))
>
> if __name__ == '__main__':
>        main()
>
> ------------------------------------------------------------------------------------
>
> When I run this, this is what I get:
> DataTableException: Wrong format for value and formatting - (2012, 2,
> 14, 15, 0, 0).
>
> I cannot make it work. Anybody can give me some hints? I am totally
> stuck.
>
> Thanks,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-visualization-api?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to