MongoDB 导出数据成 csv

【问题】

How do you export from Mongodb to CSV? (Python prefer)
The problem is to export nested complex json to flat csv with duplicate entries, thats called denormalisation.
For example json is
Putin
-bwm
-porche

for every option i need full data about user, so in excel this json looks like
name  car
Putin  bmw
Putin  porche

【回答】

将 MongoDB 中的多层数据导出为结构化二维数据,实现这种算法要考虑大数据的处理,结构化数据计算,用 python 实现存在一定难度。这类结构化数据处理用 SPL 更专业,代码很简单:

A
1 =mongo_open(“mongo://localhost:27017/local?user=test&password=test”)
2 =mongo_shell(A1,”testcar.find()”)
3 =A2.news(A2.car;~:car,A2.name:name)
4 =file(“D:\\data.csv”).export@tc(A3;)
5 >mongo_close(A1)