0

我有一百万个文档需要转换。每个文档如下所示:

{
  "_id": "00082786797c0a31ab8b5e67fb0000dc",
  "_rev": "3-d67692b1c94b936ae913bf7ea4896bed",
  "type": "Feature",
  "properties": {
    "timestamp": "2015-08-03 21:26:48.000",
    "status": "on",
    "avstatus": null,
    "speed": "38",
    "MS_DATE_TI": 1438576728000,
    "STR_DATE_T": "1438576728000"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [
      -8784866.197274148,
      4296254.156268783
    ]
  }
}

我正在尝试为每条记录创建一个基于“MS_DATE_TI”属性的新属性。最好的方法是什么?

谢谢,泰勒

4

2 回答 2

0

要么用 Python 构建一个小脚本,要么直接在浏览器中使用 PouchDB。

这是代码的样子。

var n; //The number of  documents to get for every bulkget. Use it as a limit
var lastKey; //The key used as startkey_docid parameter

while(true){
    //AllDocs to get N documents starting from lastkey
    //Update the documents locally by doing a loop
    //Send the updates to the server
    //If response.rows < limit, you probably have updated all the lines so break the loop
}
于 2016-11-14T15:03:24.107 回答
0

谢谢亚历克西斯·科特。我最终利用了我的一些 python 技能(我还没有 PouchDB 技能):)

这就是我所做的:

加载 python CouchDB 库: https ://pypi.python.org/pypi/CouchDB

阅读文档: http: //pythonhosted.org/CouchDB/

写一个小脚本

import couchdb
couch = couchdb.Server()
db = couch['avl_multi_doc']
for id in db:
    doc = db[id]
    print doc['properties']['MS_DATE_TI']
    doc['time'] = doc['properties']['MS_DATE_TI']
    db[doc.id] = doc

单击运行并观看 Matlock

于 2016-11-15T02:35:51.837 回答