我有初始的ndb来存储数据:
class Node(ndb.Model):
name = ndb.StringProperty()
tag_list = ndb.TextProperty(repeated=True)
center_point = ndb.GeoPtProperty()
我想从CSV文件导入数据。请告诉我导入数据的方法!和csv文件的结构。
答案 0 :(得分:0)
import csv
reader = csv.reader(open('nodes.csv', 'rb'), delimiter=',', quotechar='"')
for row in reader:
node = Node(
name = row[0]
tag_list = row[1].split(",")
)
node.put()
nodes.csv
name1,"tag1,tag2",""
name2,"tag3,tag4",""
name3,"tag3,tag2",""
未经测试。