Re: mongoimport + dot notation

62 views
Skip to first unread message

Osmar Olivo

unread,
Oct 3, 2012, 5:30:02 PM10/3/12
to mongod...@googlegroups.com
Unfortunately, there is currently no way of doing this using mongoimport. Though I agree it would be a great feature to have. If you feel so inclined, you should submit a feature request to 10gen at https://jira.mongodb.org/SERVER .

For now you will just have to do this breakup of the data programmatically. Either by walking through the documents and adding a loc : {} field and then in removing the loc.lat loc.long or some other programatic means. 

Thanks.

On Wednesday, October 3, 2012 8:20:00 AM UTC-4, Víctor Penela wrote:
Hi!

I have a csv I want to import to mongo. Using the --files I'm able to assign particular names to each field.

Is it possible to build fields as not simple fields but as embedded documents?

As an example, what I've tried so far
mongoimport -d test -c zip -f ,"loc.lat","loc.lon",code --type csv -drop ES.csv

The result for this is 
{
"_id" : ObjectId("506c2bc2be9fc8b35104575b"),
"loc.lat" : 37.4333,
"loc.lon" : -1.7333
}

What I'd like is to get something like:
{
"_id" : ObjectId("506c2bc2be9fc8b35104575b"),
"loc" : {
"lat" :  37.4333,
"lon" : -1.7333
        }
}

Is it possible directly via mongoimport?

Thanks!

-Víctor

Reply all
Reply to author
Forward
0 new messages