importRows Google Fusion Tables API
Question: I would like to import rows from csv file to fusion table using the Google
fusion tables API, I read [this
reference](https://developers.google.com/fusiontables/docs/v1/reference/table/importRows),
but I don't understand how to post my csv file here:
<https://www.googleapis.com/upload/fusiontables/v1/tables/---tableId---/import>

How should I attach myFile.csv to request in python ?

    
    
    request = urllib2.Request("https://www.googleapis.com/fusiontables/v1/tables/---tableID---/import")
    request.get_method = lambda: 'POST'
    response = opener.open(request).read()
    

What I already have:

    
    
    opener = urllib2.build_opener(urllib2.HTTPHandler)
    request = urllib2.Request('https://www.googleapis.com/fusiontables/v1/query?%s' % \
    (urllib.urlencode({'access_token': access_token,
                       'sql': query})),
    headers={'Content-Length':0})
    request.get_method = lambda: 'POST' 
    response = opener.open(request).read()
    print response
    

This code adds single rows to fusion table using simple SQL queries, but I
need to add 100k rows, so according to [this
reference](https://developers.google.com/fusiontables/docs/v1/sql-
reference#insertRow) I have to use the
[importRows](https://developers.google.com/fusiontables/docs/v1/reference/table/importRows)
method and not [SQL insert
statements](https://developers.google.com/fusiontables/docs/v1/sql-
reference#insertRow).

Thank you.


Answer: According to this
[documentation](https://developers.google.com/fusiontables/docs/v1/using#ImportingRowsIntoTables)
the correct URL to import rows is

    
    
    https://www.googleapis.com/upload/fusiontables/v1/tables/tableId/import
    

> **Importing rows into a table**
>
> To import more rows into an existing table, send an authenticated POST HTTP
> request to the following URI (note the **upload** in the URI below):
>
> <https://www.googleapis.com/upload/fusiontables/v1/tables/tableId/import>
>
> You must supply the row data in the message body. The row data should be CSV
> formatted data, though you may specify alternative delimiters.

Probably [this example](https://puravidaapps.com/taifunFT2.php#import) can
help somehow.

