MongoDB | Importing data from CSV file

mongoimport -h lan.ikunal.in --type csv -d hospitals -c list --headerline --drop hospital_directory.csv -u hospitals
  • –type: The input format to import: json, csv, or tsv. We are using csv so that’s what we specify.
  • -d: Specifies what database to use. We used the hospitals database.
  • -c: Specifies what collection to use. We used a collection called list.
  • --headerline: Specifies that the first row in our csv file should be the field names.
  • --drop: Specifies that we want to drop the collection before importing documents.
  • -u: specifys the user to log in
Last updated on Oct 07, 2021 22:06 UTC
Built with Hugo
Theme Stack designed by Jimmy