19/06/2020 - mongoimport

  • hi its the snail /shameful unemployed procrastinator here again
  • today i discovered another thing new
  • how to use mongoimport to import a .tsv file into mongodb
  • go google sheet online >create some columns with data and the a header row>export the file as tsv file
  • go mongodb and download the server app (just to get mongod aka mongo daemon) and the database tools (just to get mongoimport)
  • download and install the file
  • go into the bin folder and copy the url
  • start>search>views advanced settings>env variables > find "path" variable>edit>paste the url
  • go to the downloads folder, unzip the file, go to /bin and right click run command prompt OR powershell OR bash
  • go mongodb atlas>create a cluster if none > create a database if none>create a collection if none>go back to the dashboard>connect>get the connection string> open up windows notepad and store the url>edit the fields for password, database name
  • mongo atkad>account>cluster>database>collection>data entry>data field
  • i only know how to use mongoatlas which lets me ignore complicated file paths and command lines, user rights etc
  • mongo lets you skip a lot of database set up vs sql
  • wish there was a file import button somewhere on mongo cloud atlas
  • craft the command line in your notepad
  • mongo import --uri <connection string+password+databasename>  --collection <collection name> --type tsv --file <file name+.tsv> --headerline
  • use mongoimport --help to learn more about the flags
  • and theres two more steps i did, i copied the import file to the /bin, /data , /data/db
  • not sure which folder mongoimport recognises
  • please go or test which one is the recognised folder. i am not sure if the command line accepts file path instead
  • copy and paste the line into the CLI, use right click paste
  • i cannot guarantee its successful, but you can use the --help flag or go stackoverflow
  • go mongo atlas check the data
  • if it works, as in you see the file data appearing in your collection, you can delete the data from the cloud and add in your actual data

Comments

Popular posts from this blog

green tea bitch

song

20231104