MongoDB does not support the direct import of Excel files, so to do that, we will use a function built into Excel.
The mongoimport
utility supports only JSON, CSV, and TSV files. Therefore, to get your data from Excel into MongoDB, the best option is to save it as a CSV file, and then use mongoimport
to import it.
In Excel:
After you perform the preceding steps, you can use the previous recipe to import the file.
If you think that's too easy though, you can import the Excel file into a Pandas DataFrame using read_excel
, write the entire DataFrame to a CSV file using to_csv
, and then import it using mongoimport
. I highly recommend the first and much easier option.