Feeling inspired from the success of the script that I wrote to export from Google Analytics to Google Docs , I decided to see if I could reuse most of the code for other Google CSV exports. My first sub-project was to tackle Google Trends.
I made the necessary front end changes to put in the new links and collect the correct export URLs. Generally everything worked on the backend as well after only a few minor tweaks. However, I kept receiving a lot of junk in the export and the content was not legible.
There seems to be some issue with the format of the CSV file being delivered by Google Trends. It opens fine is a pure text editor like Notepad++ , but the browser recognized thousands of "invalid" characters in the export. Basically, the CSV contains a null value in between every other valid character and it included rare form feed characters at the beginning and end of the file. These invisible characters were blowing up the import to Google Docs so that while I would receive a "success" message for the upload, everything came out as gobbledegoop .
After multiple attempts to try to request a different file format, I finally decided to work a little string magic using RegEx. I stripped out all of the junk characters before sending it up to Google Docs and voila! Everything works fine now.
Unfortunately, Google Trends only allows exports for keyword comparisons at the moment, but not for website data. In the meantime though, for anyone doing SEO Keyword research, this could be of some valuable use to you.
Here are the links:
Download GM script directly
Greasemonkey Script Page