mongoimport with comma in values

36 views
Skip to first unread message

Todd Greanier

unread,
Oct 22, 2012, 9:38:45 PM10/22/12
to mongod...@googlegroups.com
I am importing some JSON documents and some of them have a value with commas in it, like so:

...
value: "ABC, DEF, GHI"

This is the "name" of something in a SQL database I am trying to import into Mongo. It is not three names in one value. When importing with mongoimport, it fails, I believe because mongoimport is getting confused about the commas. Is there a way to escape these out either in pre-processing (when building the json) or during the import?

Thanks,

Todd

Stephen Lee

unread,
Oct 23, 2012, 12:32:06 PM10/23/12
to mongod...@googlegroups.com
Hi Todd,

I wasn't able to reproduce this using mongoimport v2.2:

> mongoimport --port 30001 -d test -c comma --file test.js 
connected to: 127.0.0.1:30001
Tue Oct 23 12:30:16 imported 1 objects
> cat test.js
{ a: "a,b,c,d,e", b: "f,g,h,i,j" }
> mongo --port 30001
MongoDB shell version: 2.2.0
connecting to: 127.0.0.1:30001/test
> db.comma.find()
{ "_id" : ObjectId("5086c6187f9c0acd2a40cb14"), "a" : "a,b,c,d,e", "b" : "f,g,h,i,j" }

What version of mongoimport are you using?

-Stephen
Reply all
Reply to author
Forward
0 new messages