mongodb - mongoexport语法错误消息

标签 mongodb csv mongoexport

我正在使用mongodb 2.4.3,但无法使mongoexport正常工作。我通过每个命令得到的错误消息是:"JavaScript execution failed: SyntaxError: Unexpected identifier"
起初,我认为问题出在我的查询参数上,这很长。但是find()在查询中工作正常,所以我知道语法还可以。然后,我使用查询创建了一个新集合,并尝试使用以下命令导出该集合:
mongoexport --db Oct2012 --collection sept8subset --csv --fields "text","created_at","user.screen_name","user.followers_count" --out sept8.csvmongoexport --db Oct2012 --collection sept8subset --csv --fields text,created_at,user.screen_name,user.followers_count --out sept8.csvmongoexport -d Oct2012 -c sept8subset --csv --fields text,created_at,user.screen_name -o sept8.csvmongoexport --db Oct2012 --collection sept8subset --dbpath ~/db (should need dbpath as mongod instance is running)mongoexport --db OCt2012 -collection sept8subset -o sept8.txtmongoexport --db Oct2012 --collection sept8subset
在每种情况下,我都得到"JavaScript execution failed: SyntaxError: Unexpected identifier"。该SyntaxError可能在哪里?

我要复制的集合有50,339个对象。如果mongoexport无法处理的太大,我从集合中取出了5个文档以制作一个新集合。然后,我尝试使用与上述相同的命令结构将其导出。我仍然收到相同的错误消息。

现在,我想知道问题是否在于mongoexport无法处理涉及日期的数据。 MongoDB文档指出,我可能想使用客户端驱动程序编写自己的导出脚本。

有人知道我的问题在这里吗?非常感谢您的帮助。

最佳答案

我发现从mongo客户端运行mongoexport(就像我以前所做的那样)是不正确的。 Mongoexport在命令提示符下执行。

关于mongodb - mongoexport语法错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16307107/

相关文章:

php - 将 CSV 转换为 PHP 数组 - 结束行问题 (CR LF)

mongodb - 从 MongoDB 导出 csv

node.js - Nodejs等待查询

mongodb - 在mongodb中查找LineString附近的点,按距离排序

c# - 将 FilterDefinition<TDocument> 转换为我可以在 mongo shell 中运行的常规 json mongo 查询

php - 导入 CSV 时出现此错误 DateTime::__construct(): Failed to parse time string

python - 使用 python 在列表中查找明确的单词

mongodb - 使用查询的 MongoExport

MongoDB 从多个集合中导出数据

node.js - Mongoose - 如何在键中使用变量