Loading Data into Your Sandbox Cluster

Hello,

Can anybody tells why I can’t load movie data into my sandbox cluster? The movie directory has been successfully created but it is not getting loaded using the “load” function. How do I solve this issue?

image

@Hugues_91518 Did you launch the shell from the same directory as the “loadMovieDetailsDataset.js” file? If not then you’ll need to alter the path while doing the load command or relaunch the shell from that folder.

https://docs.mongodb.com/manual/reference/method/load/

HTH,
Mike

2 Likes

@Hugues_91518 When I unzipped the handout, I got 3 directories in my current directory, one of which is “loadMovieDetailsDataset” containing “loadMoviewDetailsDataset.js”. I can do one of the following :

  1. run the mongo shell from within this directory,
  2. move/copy the .js file to my current directory,
  3. reference the .js file from within mongo shell as
    load(“loadMovieDetailsDataset/loadMovieDetailsDataset.js”)

Hope this helps
Tim

3 Likes

@Mike_67094 What did you mean by launching the shell from the same directory as the “loadMovieDetailsDataset.js”? Would please clarify this?

@Tim_93902 I only got one directory with this file:

image

Does it have anything to do with the directory itself?

@Hugues_91518 I just meant, once you have navigated to the folder containing the JS file, launch the MongoSHell, then type load(“loadMovieDetailsDataset.js”) . This is just for convenience, you could launch the MongoShell from another directory but then you would need to account for that in the path to the JS file when you typed the load("") command, etc.

HTH,
Mike

2 Likes

@Hugues_91518 OK, I’m not sure what your question means, but here is what I did -

I am running Windows 10
My home directory is \Users\tim on the C: drive
I created a directory in my home directory called M001 (\Users\tim\M001)
I unzipped the handout file into \Users\tim\M001
My handout file contained 3 directories, but some handouts only contain 1 file.
One of my directories is \Users\tim\M001\loadMovieDetailsDataset
In a Command window, I typed in
cd \Users\tim\M001\loadMovieDetailsDataset
then typed
dir
this shows
12/10/2018 17:00 1,381,666 loadMovieDetailsDataset.js
now I type in my mongo shell start command
mongo "mongodb://sandbox…
which gives me a mongo shell prompt
now I can type in my commands
use video
load(“loadMovieDetailsDataset.js”)

and the work is done.
Tim

3 Likes

Perfect! Have fun! You should now be able to type “show collections” and you should see your new collection “movieDetails” collection created by the script.

2 Likes

@Tim_93902,

Thank you, Tim!

The command I have been missing was “use video”. It works. Again, thanks much!

image

2 Likes

@Mike_67094 Thank you, Mike! I finally got it done.

Again, thanks!

Navigate via CMD or Terminal to your js file. then run below command:

load(“filename”)

Hope this will solve your problem

Well, no :slight_smile: You’re forgetting to start the Mongo shell.