mongoexport聚合导出到csv文件 [英] mongoexport aggregate export to a csv file

查看:537
本文介绍了mongoexport聚合导出到csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将聚合结果保存到csv文件中.

I want to save the result from an aggregation into a csv file.

使用mongo cmd线工具,我可以这样做以获得所需的结果:

Using the mongo cmd line tool I can do this to get the results I want:

db.compras.aggregate({ $group : { _id : "$data.proponente", total : { $sum : "$price" } }}

我如何将其转换为将结果保存到csv的mongoexport命令?

How would I translate this into a mongoexport command that saves results into a csv?

推荐答案

您无法运行通过mongoexport查询aggregate(). mongoexport工具旨在通过查询过滤器导出更基本的数据,而不是完全聚合和数据处理.不过,您可以使用喜欢的MonaDB 语言驱动程序轻松编写简短脚本.

You can't run aggregate() queries through mongoexport. The mongoexport tool is intended for more basic data export with a query filter rather than full aggregation and data processing. You could easily write a short script using your favourite language driver for MongoDB, though.

这篇关于mongoexport聚合导出到csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆