1

我有初始 ndb 来存储数据:

class Node(ndb.Model):
  name = ndb.StringProperty()
  tag_list = ndb.TextProperty(repeated=True)
  center_point = ndb.GeoPtProperty()

我想从 CSV 文件导入数据。请教我导入数据的方法!以及csv文件的结构。

4

1 回答 1

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()

节点.csv

name1,"tag1,tag2",""
name2,"tag3,tag4",""
name3,"tag3,tag2",""

未经测试。

于 2012-08-16T12:43:53.283 回答