Why not let your own script fetch the statistics directly from google adsense reporting site? It's always much easier to have the data locally in your own database, and then create scripts to display the stats in the way you are interested in.
Comments
Cool tutorial