James Gould
James Gould

Reputation: 4702

Mongoimport import error - tab delimited CSV detected as JSON

I'm trying to import a .csv file into a MongoDB database with the mongoimport utility. The .csv file has a headerline as follows:

countryCode streetName postalCode placeName adminName1 adminCode1 adminName2 adminCode2 adminName3 adminCode3 latitude longitude accuracy

And the rest of the data is structured as following:

GB Broad Street AB10 1AA George St/Harbour Ward Scotland SCT Aberdeen City S12000033 57.1482280891232 -2.09664786079318 6

I get the following error when using the command:

mongoimport -d mydb -c locations --file geodata.csv --headerline error validating settings: can not use --headerline when input type is JSON

Can anyone tell me why? The csv file only has 130,000 records so it's not a size issue.

Upvotes: 1

Views: 1629

Answers (1)

notionquest
notionquest

Reputation: 39186

The --headerline can be used only for csv and tsv file formats.

When you are importing CSV, please use "--type csv" in your command.

--headerline If using --type csv or --type tsv, uses the first line as field names. Otherwise, mongoimport will import the first line as a distinct document.

If you attempt to include --headerline when importing JSON data, mongoimport will return an error. --headerline is only for csv or tsv imports.

Upvotes: 3

Related Questions