我正在按照本教程关于如何将GeoJSON文件导入MongoDB。 http://www.adityabansod.net/2014/11/
当我到达命令时:
mongoimport --db sfstreets --collection streets < sweeping_clean.json
我收到此错误:
失败:错误处理文档#2:无效字符':'正在查找 价值开始
这是文件的外观(或前三行):
"features": [
{ "type": "Feature", "properties": { "CNN": "13798000", "WEEKDAY": "Fri", "BLOCKSIDE": null, "BLOCKSWEEP": "1642922", "CNNRIGHTLE": "R", "CORRIDOR": "Corona St", "FROMHOUR": "12:00", "TOHOUR": "14:00", "HOLIDAYS": "N", "WEEK1OFMON": "Y", "WEEK2OFMON": "N", "WEEK3OFMON": "Y", "WEEK4OFMON": "N", "WEEK5OFMON": "N", "LF_FADD": "221", "LF_TOADD": "299", "RT_TOADD": "298", "RT_FADD": "222", "STREETNAME": "CORONA ST", "ZIP_CODE": "94127", "NHOOD": "Ingleside Terrace", "DISTRICT": null }, "geometry": { "type": "LineString", "coordinates": [ [ -122.466597727410232, 37.725924475312347 ], [ -122.466538207925296, 37.726008134595666 ], [ -122.466545014733981, 37.72609265587532 ], [ -122.466622699195298, 37.726149395842491 ], [ -122.466715781686275, 37.726165938701833 ], [ -122.466832802132032, 37.726142308565613 ], [ -122.466897677698327, 37.726061377866067 ], [ -122.466866500919153, 37.725977262576407 ], [ -122.4667409099483, 37.725929815795411 ], [ -122.466597727410232, 37.725924475312347 ] ] } },
{ "type": "Feature", "properties": { "CNN": "13576001", "WEEKDAY": "Fri", "BLOCKSIDE": "East", "BLOCKSWEEP": "1635302", "CNNRIGHTLE": "L", "CORRIDOR": "West Point Rd", "FROMHOUR": "09:00", "TOHOUR": "11:00", "HOLIDAYS": "N", "WEEK1OFMON": "Y", "WEEK2OFMON": "Y", "WEEK3OFMON": "Y", "WEEK4OFMON": "Y", "WEEK5OFMON": "Y", "LF_FADD": "1", "LF_TOADD": "199", "RT_TOADD": "198", "RT_FADD": "2", "STREETNAME": "WEST POINT RD", "ZIP_CODE": "94124", "NHOOD": "Hunters Point", "DISTRICT": null }, "geometry": { "type": "LineString", "coordinates": [ [ -122.380990296638643, 37.735956150208381 ], [ -122.380638929041751, 37.735578610786696 ], [ -122.380275721328843, 37.735358309670289 ], [ -122.379832804134111, 37.735239767490803 ], [ -122.379414567742032, 37.735244675031652 ] ] } },
知道我做错了吗?
答案 0 :(得分:1)
在meteorjs中,使用mongodb,导入我使用:
mongoimport -h localhost:3001 --db [DB] --collection [COLLECTION] --type json --file [data.json] --jsonArray
不知道是否有帮助。
答案 1 :(得分:0)
我仍然不明白这个问题是什么,但我找到了一个解决方法:
我创建了一个脚本,用于存储&#34;功能&#34;的每个元素。在数组内部,并使用db.<collection name>.insert(<array name>);
将数组插入集合中
这对我来说很有把握,并为我节省了大量的体力劳动。
答案 2 :(得分:0)
您应该仅在文件开头和结尾的JSON方括号中保留数组,并为mongoimport保留--jsonArray参数。