9

I wrote a script that uses mongoimport to load csv files into mongodb. When I run this for two similar csv files (of the same type) both upload fine, however I can only access one of them from the mongodb shell. Here is a transcript of a mongodb shell session:

> show collections
3mLgQAYJCq6_20110802
eTByWMY7zO6_20110802NonUniCode
system.indexes
> db.3mLgQAYJCq6_20110802
Thu Aug 18 18:44:49 SyntaxError: missing ; before statement (shell):1
> db.eTByWMY7zO6_20110802NonUniCode
vh.eTByWMY7zO6_20110802NonUniCode

However, I can access both collections from a python script and using mongoexport. I suspect there is a problem with the 3mLgQAYJCq6_20110802 file but I don't know where to start looking. Any ideas?

Kelly
  • 40,173
  • 4
  • 42
  • 51
DavidA
  • 91
  • 1
  • 1
  • 2

3 Answers3

11

This works for me when my collection names include special characters:

db["3mLgQAYJCq6_20110802"].findOne();
Hasturkun
  • 35,395
  • 6
  • 71
  • 104
code_monk
  • 9,451
  • 2
  • 42
  • 41
3

The collection name should start with a letter or the underscore.You can get the info about the naming convention for the collections in mongodb from below link- http://www.mongodb.org/display/DOCS/Collections

azhar_salati
  • 1,554
  • 5
  • 28
  • 54
-1

lovely collection names... it's probably because it's starts with a 3.

Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176