本文介绍了`字段不能相同:''和'''mongoimport错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图导入csv到我的本地机器上的mongodb。我用下面条命令从shell:

i'm trying to import a csv into mongodb on my local machine. I used the following commmand from the shell:

mongoimport -d mydb -c things --type csv --file /Users/..../agentsFullOutput.csv --headerline

我得到以下错误:

Failed: fields cannot be identical: '' and ''

我找不到什么意思。我究竟做错了什么?顺便说一下,csv文件是mongoexport的结果。

I can't find anything on what that means. What am I doing wrong? The csv file, by the way, is the result of a mongoexport.

这里是列标题和一些数据:

here are the column headers and some data:

_id build_profile   company_address company_name    company_website created_at  device _token   downloaded_app  email   first_name  last_name   is_proapp   modified_at mobile_phone    terms_accepted_at   license_number  broker_id   join_unique_url linkedin_profile_id billing_customer_id billing_zip mobile_phone    office_phone    vendors_count   clients_count   app_client
ObjectID(52ab245b763f4aec448b6763)  0   California  Lateral test    2014-01-01T08:19:05.470Z            test    test    test        2015-04-18T05:16:37.155Z    (123) 123-1234                          zip (123) 123-1234      10  5
ObjectID(52b46bfc763f4ad9198b45ab)      7928    test    test    2014-01-01T08:19:05.470Z                Jennifer    Chase       2015-04-15T17:05:17.114Z            5551112     jennifer-chase      test    7071            22  64


推荐答案

我有同样的问题。我在Excel中打开一个CSV文件,以按摩它,并将其保存回来。当尝试使用mongoimport命令将其导入到Mongo中时,我得到了相同的错误消息,我有相同的值。我重复检查了列标题,以确保没有任何相同的值。

I had the exact same issue. I was opening up a CSV file in Excel to massage it and saving it back out again. While trying to import it into Mongo using "mongoimport" command I was getting the same error message that I had identical values. I checked the columns headings over and over to make sure there weren't any identical values.

我最终尝试从Excel中重新保存文件使用Windows Comma Separated的(.csv)逗号分隔值(.csv)通用格式部分的中找到的,从格式下拉菜单中,而不是默认选项。

I eventually tried re-saving the file from Excel using the "Windows Comma Separated (.csv)" option from the Format dropdown menu instead of the default "Comma Separated Values (.csv)" found in the "Common Format" section.

工作完美。

这篇关于`字段不能相同:''和'''mongoimport错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 21:48