Search code examples
pythondatabasegoogle-app-enginegoogle-docsgoogle-docs-api

Populating data in appengine database from a csv file or spreadsheet from google docs


I am uisng webapp2 on google app engine my database model has the following schema:

class Match(db.Model):
    start_date = db.DateProperty()
    start_time = db.TimeProperty()
    team1 = db.StringProperty()
    team2 = db.StringProperty()
    venue = db.StringProperty()
    result = db.IntegerProperty()

And i have a csv file or say google spreadsheet, with all the data there are around 150 rows.

Putting all the values manually is a big pain. Could anyone please suggest me how to update the database?


Solution

  • You could create a page that you can POST the contents of the CSV file to, and then use the Python csv module to read the file and loop over the rows, inserting model instances as you go.