失败:mongoimport 中错误处理文档

Failed: error processing document in mongoimport

我在读取 csv 文件时遇到以下错误:

失败:错误处理文档 #1:文字 new 或 null 中的无效字符 'a'(应为 'e' 或 'u')

有一些空白字段,我怀疑需要将其显示为 'null' 才能正确阅读。我说得对吗?

CSV 样本:

姓名,年份,battle_number,attacker_king,defender_king,attacker_1,attacker_2,attacker_3,attacker_4 ,defender_1,defender_2,defender_3,defender_4,attacker_outcome,battle_type,major_death,major_capture,attacker_size,defender_size,attacker_commander,defender_commander,夏天,地点,地区,备注

金牙之战,298,1,Joffrey/Tommen Baratheon,Robb Stark,Lannister,Tully,win,pitched battle,1,0,15000,4000,Jaime Lannister ,"Clement Piper, Vance",1,金牙,西境,

戏子福特之战,298,2,Joffrey/Tommen Baratheon,Robb Stark,Lannister,Baratheon,win,ambush,1,0,120,Gregor Clegane,Beric Dondarrion,1,戏子福特,河间地,

我猜你没有用 --type csv 指定文件类型所以 mongoimport假设你默认导入一个 JSON 文件

--> 尝试使用 --type csv --headerline

导入

在 AWS 文档中,它在 CSV 文件导入中缺少以下 3 行。

    --type=csv \
--headerline \
--ignoreBlanks \

在我添加以下 3 行代码后,CSV 文件成功导入到 AWS documentdb。

mongoimport --ssl \
--host="sample-cluster.node.us-east-1.docdb.amazonaws.com:27017" \
--collection=sample-collection \
--db=sample-database \
--type=csv \
--headerline \
--ignoreBlanks \
--file=<yourFile> \
--numInsertionWorkers 4 \
--username=sample-user \
--password=abc0123 \
--sslCAFile rds-combined-ca-bundle.pem