Re: Mongodb import error message

2,960 views
Skip to first unread message

ROBERT KASS

unread,
Jun 15, 2011, 10:04:42 PM6/15/11
to mongodb-user
from command line in mongodb

mongoimport --host localhost --db test.db --collection ma144 --file /
home/robert/test.csv --headerline upsert

SyntaxError: missing ; before statement (shell)

I am using Fedora 14.

Does anyone have any idea what I am doing wrong. New at this.

Thank you

Nat

unread,
Jun 15, 2011, 11:04:57 PM6/15/11
to mongod...@googlegroups.com
what version of mongodb do you use? how does your csv file look like?

ROBERT KASS

unread,
Jun 15, 2011, 11:21:56 PM6/15/11
to mongodb-user


On Jun 15, 11:04 pm, Nat <nat.lu...@gmail.com> wrote:
> what version of mongodb do you use? how does your csv file look like?

mongodb 1.8.1

test.csv

name address tel
joe smith 145 jones street 508-532-0603

Nat

unread,
Jun 16, 2011, 12:11:03 AM6/16/11
to mongod...@googlegroups.com
- mongoimport doesn't use shell. Are you sure that you call the right executable?
- note that upsert  should really be --upsert and you should specify upsertFields especially if you don't have _id field

ROBERT KASS

unread,
Jun 16, 2011, 12:33:28 AM6/16/11
to mongodb-user
Hi Nat,

Thank you for the help.

I am using putty and mondodb appears to be functioning. Is this not
the case? Every other command I am running appears to be working.

I will try --upsert and upsertFields.

Thank you

Nat

unread,
Jun 16, 2011, 12:36:30 AM6/16/11
to mongod...@googlegroups.com
I mean the error message is the indication that a javascript is executing from mongo (shell) instead of mongoimport.

ROBERT KASS

unread,
Jun 16, 2011, 12:39:04 AM6/16/11
to mongodb-user
As I am quite the newbie any ideas on what I need to do?

Nat

unread,
Jun 16, 2011, 12:44:18 AM6/16/11
to mongod...@googlegroups.com
try running it without any options... it should show something like

$ mongoimport
connected to: 127.0.0.1
no collection specified!
options:
  --help                  produce help message
  -v [ --verbose ]        be more verbose (include multiple times for more
                          verbosity e.g. -vvvvv)
  -h [ --host ] arg       mongo host to connect to ( <set name>/s1,s2 for sets)
  --port arg              server port. Can also use --host hostname:port
  --ipv6                  enable IPv6 support (disabled by default)
  -u [ --username ] arg   username
  -p [ --password ] arg   password
  --dbpath arg            directly access mongod database files in the given
                          path, instead of connecting to a mongod  server -
                          needs to lock the data directory, so cannot be used
                          if a mongod is currently accessing the same path
  --directoryperdb        if dbpath specified, each db is in a separate
                          directory
  -d [ --db ] arg         database to use
  -c [ --collection ] arg collection to use (some commands)
  -f [ --fields ] arg     comma separated list of field names e.g. -f name,age
  --fieldFile arg         file with fields names - 1 per line
  --ignoreBlanks          if given, empty fields in csv and tsv will be ignored
  --type arg              type of file to import.  default: json (json,csv,tsv)
  --file arg              file to import from; if not specified stdin is used
  --drop                  drop collection first
  --headerline            CSV,TSV only - use first line as headers
  --upsert                insert or update objects that already exist
  --upsertFields arg      comma-separated fields for the query part of the
                          upsert. You should make sure this is indexed
  --stopOnError           stop importing at first error rather than continuing
  --jsonArray             load a json array, not one item per line. Currently
                          limited to 4MB.

If not, something is wrong with your binary

ROBERT KASS

unread,
Jun 16, 2011, 12:45:20 AM6/16/11
to mongodb-user
When I login to mongo the console says mongoDB shell version: 1.8.1

Nat

unread,
Jun 16, 2011, 12:45:43 AM6/16/11
to mongod...@googlegroups.com
also note that you forgot --type csv so it would assume that your file type is json.

Nat

unread,
Jun 16, 2011, 12:46:47 AM6/16/11
to mongod...@googlegroups.com
If you want to import, use mongoimport not mongo.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

ROBERT KASS

unread,
Jun 16, 2011, 12:48:07 AM6/16/11
to mongodb-user
When I enter mongoimport I get:

ReferenceError: mongoimport is not defined (shell)

Nat

unread,
Jun 16, 2011, 12:53:20 AM6/16/11
to mongod...@googlegroups.com
Run it from unix shell not from mongodb shell.
-----Original Message-----
From: ROBERT KASS <zdsapp...@gmail.com>
Sender: mongod...@googlegroups.com
Date: Wed, 15 Jun 2011 21:48:07
To: mongodb-user<mongod...@googlegroups.com>
Reply-To: mongod...@googlegroups.com
Subject: [mongodb-user] Re: Mongodb import error message

ROBERT KASS

unread,
Jun 16, 2011, 12:54:38 AM6/16/11
to mongodb-user
ok thank you Nat. I really appreciate the help.

Brijesh Janardhanan

unread,
May 8, 2016, 7:50:57 PM5/8/16
to mongodb-user, nat....@gmail.com
This was useful! Thank you.
Reply all
Reply to author
Forward
0 new messages