I'm trying to use Python to take csv files and use them to update (or replace) tables in Fusion Tables. I found the "Python client library for Fusion Tables" on googles' site and downloaded them as well as the two required dependencies:
- python-oauth2 library: http://github.com/simplegeo/python-oauth2
- python-oauth2 dependency, httplib2: http://code.google.com/p/httplib2/
I've installed all three on python 2.7 like required and just can't seem to figure out how to actually get it to work. I've even tried to get their samples to work with no luck either. At this point let me say that I'm not a programmer and don't know python. However, I can grasp it enough (and look at and modify code) pretty well though and used python to write the scripts that export from SDE to shapefiles, then convert the shapefiles to KML using GDAL and then convert the KML to CSV using elementtree.
Does anybody know of a good resource to look at for help in doing what I'm trying to do? All I can find online is a few people saying they did it, with no explanation, and a ton of links to the google code (which has no documentation)
Thanks in advance,
Adam
Best Answer
In order to upload csv to FusionTables, you'll need to make sure you authenticate first. I see you've included the dependencies for OAuth, but if you're just trying to have a script do a simple upload, it'd be easiest to use ClientLogin (and you don't need the dependencies). A skeleton of the code should look something like this (adapted from the sample code in the python library you referenced):
If you want to add rows to an existing FusionTable, that'll be trickier. It would probably take parsing out the CSV with
csv.DictReader
or something and then iterating over that and uploading those rows using something like......for each row.