我一直在尝试使用所有字段从http://www.transtats.bts.gov/DL_SelectFields.asp?Table_ID=293&DB_Short_Name=Air%20Carriers导入文件。
为此我从终端做了以下命令:
mongoimport -d local -c flightdata --type csv --file 1073242969_T_T100_SEGMENT_ALL_CARRIER_modified.csv --headerline
问题是当我运行命令时,我得到以下输出:
connected to: 127.0.0.1
Tue Dec 17 21:58:34.207 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:34.207 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:34.208 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:34.208 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:34.209 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:34.210 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:34.210 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:34.211 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:34.211 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:37.035 Progress: 8487360/56679929 14%
Tue Dec 17 21:58:37.035 30900 10300/second
Tue Dec 17 21:58:40.004 Progress: 16952746/56679929 29%
Tue Dec 17 21:58:40.004 61600 10266/second
Tue Dec 17 21:58:43.040 Progress: 24734143/56679929 43%
Tue Dec 17 21:58:43.040 89900 9988/second
Tue Dec 17 21:58:46.042 Progress: 32521258/56679929 57%
Tue Dec 17 21:58:46.042 118100 9841/second
Tue Dec 17 21:58:49.007 Progress: 40172878/56679929 70%
Tue Dec 17 21:58:49.007 145800 9720/second
Tue Dec 17 21:58:52.021 Progress: 48124064/56679929 84%
Tue Dec 17 21:58:52.021 174600 9700/second
Tue Dec 17 21:58:54.935 check 9 205716
Tue Dec 17 21:58:55.032 E11000 duplicate key error index: local.flightdata.$_id_ dup key: { : null }
Tue Dec 17 21:58:55.032 imported 205715 objects
但是当我去检查数据库时:
>use local
>db.flightdata.count()
1
所以这意味着只加载了第一条记录。还尝试使用未加引号的字段并引用。
关于我做错了什么想法?
编辑: 标题如下
"DEPARTURES_SCHEDULED","DEPARTURES_PERFORMED","PAYLOAD","SEATS","PASSENGERS","FREIGHT","MAIL","DISTANCE","RAMP_TO_RAMP","AIR_TIME","UNIQUE_CARRIER","AIRLINE_ID","UNIQUE_CARRIER_NAME","UNIQUE_CARRIER_ENTITY","REGION","CARRIER","CARRIER_NAME","CARRIER_GROUP","CARRIER_GROUP_NEW","ORIGIN_AIRPORT_ID","ORIGIN_AIRPORT_SEQ_ID","ORIGIN_CITY_MARKET_ID","ORIGIN","ORIGIN_CITY_NAME","ORIGIN_STATE_ABR","ORIGIN_STATE_FIPS","ORIGIN_STATE_NM","ORIGIN_COUNTRY","ORIGIN_COUNTRY_NAME","ORIGIN_WAC","DEST_AIRPORT_ID","DEST_AIRPORT_SEQ_ID","DEST_CITY_MARKET_ID","DEST","DEST_CITY_NAME","DEST_STATE_ABR","DEST_STATE_FIPS","DEST_STATE_NM","DEST_COUNTRY","DEST_COUNTRY_NAME","DEST_WAC","AIRCRAFT_GROUP","AIRCRAFT_TYPE","AIRCRAFT_CONFIG","YEAR","QUARTER","MONTH","DISTANCE_GROUP","CLASS","DATA_SOURCE",
无法单独找到ID字段
答案 0 :(得分:1)
看起来你的所有记录都有_id字段,该字段应该是唯一的 - 但它们都具有相同的值,' null'。 ' mongoimport'有一个不幸的属性,只检查前十个和最后一个文件的成功插入。因此,这11项检查会得到10个错误。
EDIT 证明您正在尝试将其导入" local"存在供系统使用(复制)的数据库,你不应该把自己的集合放在那里。
如果您选择将数据库命名为" local"你的导入将会成功。