Pergunta

I cannot figure out why im producing this error when trying to do a simple export of 3 fields to a .csv file for mongodb. My code is as follows:

c:mongodb24\bin>mongoexport -db local -c pets -f type,name, color --csv -o c:\Data\CSC 451\spreadsheet.csv

Error: too many positional options

I'm wanting to export the type, name, and color data into the spreadsheet csv file.

Foi útil?

Solução

Correct answer:

c:mongodb24\bin>mongoexport -db local -c pets -f type,name,color --csv -o c:\Data\CSC451\spreadsheet.csv

Outras dicas

There are two ways to solve this.

1.) remove the space inthe filepath

c:mongodb24\bin>mongoexport -db local -c pets -f type,name,color --csv -o c:\Data\CSC451\spreadsheet.csv

2.)surround the filepath in quotes

c:mongodb24\bin>mongoexport -db local -c pets -f type,name,color --csv -o "c:\Data\CSC 451\spreadsheet.csv"

Windows doesn't like Space's in the file path so you either have to remove the space, or if you can't do that without affecting something else you need to wrap it in double quotes.

EDIT: Windows requires the query to be surrounded in double quotes while strings are surrounded in single quotes. In Linux the inverse is true, strings in double quotes and the query in single.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top