Search code examples
jsonmongodbmongoimport

Mongoimport not finding file?


mongoimport --uri mongodb+srv://gtye:<PASSWORD>@dxgraph.rymok.mongodb.net/dxgraph-db --collection dxgraph-collection --type json --file ~/DxHero%20Godot/Data/postgres_export.json

returns

2021-05-25T12:58:05.538-0400    Failed: open /Users/gtye/DxHero%20Godot/Data/postgres_export.json: no such file or directory
2021-05-25T12:58:05.538-0400    0 document(s) imported successfully. 0 document(s) failed to import.

But I know it's there!!

enter image description here

It's literally right here!! What the heck is going on?


Solution

  • %20 is a URI escaping mechanism. It doesn't work in the shell.

    Try:

    mongoimport --uri mongodb+srv://gtye:<PASSWORD>@dxgraph.rymok.mongodb.net/dxgraph-db --collection dxgraph-collection --type json --file ~/"DxHero Godot/Data/postgres_export.json"