background
要读一个多个json格式的文件,不想写解析器(懒,就略微学了一下mongodb读文件
ref
https://docs.mongodb.com/manual/
(mongoldb manual)
http://mac.softpedia.com/get/Developer-Tools/MongoBooster.shtml#download (mongobooster- a graphical user interface for connecting to MongoDB servers and managing databases)
http://api.mongodb.com/python/current/tutorial.html
(pymongo-a Python distribution containing tools for working with MongoDB)
评测
sudo mongod
然后打开mongobooster,connect之后把json文件import进去
也可以用mongo shell,一些命令
show dbs
use <db>
mongoimport --host=127.0.0.1 --db test --collection restaurants --drop --file <filename>
show collections
利用pymongo操作mongodb的一些常用代码
import pymongo
from pymongo import MongoClient
client = MongoClient('mongodb://127.0.0.1:27017/')
db = client.<db>
line = db.<collection>
for l in line:
for key in l:
if key==x:
l[key]=y