I want to build a chart to google fusion table. I know there is an option to do it with fusion table but I need to do that using google spreadsheet.
How do I import a private fusion table to a spreadsheet?
function getdata(authToken) {
query = encodeURIComponent("SELECT * FROM tableid");
var URL = "http://www.google.com/fusiontables/api/query?sql=" + query;
var response = UrlFetchApp.fetch(URL, {
method: "get",
headers: {
"Authorization": "GoogleLogin auth=" + authToken,
}
});
return response.getContentText();
}
The code above gives me the table headers only.
After a deep research, finally i figured it out after a deep search and reading here. This is how it looks for the code google docs spreadsheet app script:
After that you can do whatever you want in the spreadsheet. BTW, I still think there is a simple way to import a private table into a spreadsheet automaticly.
There's a nice article describing how to access Fusion Tables from Apps Scripts:
http://googleappsdeveloper.blogspot.com/2011/09/using-fusion-tables-with-apps-script.html
There's a link to some sample code, which you can adapt to import your Fusion Table data to a spreadsheet.
Don't set each cell individually as in the example below unless you need to process each bit of data. Using this is about 10x faster: