[英]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:我在谷歌应用引擎上使用 uisng webapp2 我的数据库 model 具有以下架构:
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.我有一个 csv 文件或谷歌电子表格,所有数据大约有 150 行。
Putting all the values manually is a big pain.手动输入所有值是一件很痛苦的事情。 Could anyone please suggest me how to update the database?
谁能建议我如何更新数据库?
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.您可以创建一个页面,您可以将 CSV 文件的内容发布到该页面,然后使用 Python
csv
模块读取文件并循环遍历行,插入 model 实例作为 go。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.