0

I use Linux, and in a local folder I have myriad of files (with no extension, but they are JSON array files).

I would like to import all of them into the database (coches) and collection (dtc) created in mongo.

I tried several codes found in different questions (1, 2) with no success. This is a list of files found in my local folder, but there are many more.

/media/mario/prueba/2020-02-25_00-30-33_588844_0Auy
/media/mario/prueba/2020-02-25_06-26-02_816819_KXbU
/media/mario/prueba/2020-02-25_07-07-22_868748_DCmL
/media/mario/prueba/2020-02-25_16-02-12_371020_eYjf

This is an example I tried unsuccessfully:

for filename in *; do mongoimport -db coches --collection dtc --file "$filename"  done;

I am new no Mongo and would like to know how to deal with this situation.

How can I import plenty of JSON files (unextensioned) to the database coches and collection dtc?

antecessor
  • 2,688
  • 6
  • 29
  • 61
  • What do you mean by 'unsuccessfully'? What error did you get? What happens when you do it for just one file? 'mongoimport --db coches --collection dtc --file ' – GeertPt Mar 25 '20 at 11:13
  • The **semicolon** should be after `"$filename"` rather than done. – Nitish Mar 25 '20 at 11:39

0 Answers0