- Python Business Intelligence Cookbook
- Robert Dempsey
- 185字
- 2021-07-30 09:51:50
Importing an Excel file into MongoDB
MongoDB does not support the direct import of Excel files, so to do that, we will use a function built into Excel.
Getting ready
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.
How to do it…
In Excel:
- Go to the File menu.
- Select Save As.
- Save the file in the Comma Separated Values (CSV) format.
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.
How it works…
This recipe works almost exactly like our previous recipe for importing a CSV file; only here, we start with an Excel file, which we save as a CSV file.
- Data Visualization with D3 4.x Cookbook(Second Edition)
- 從零開始構建企業級RAG系統
- Redis Applied Design Patterns
- Access 數據庫應用教程
- Raspberry Pi 2 Server Essentials
- Python忍者秘籍
- 單片機C語言程序設計實訓100例
- 編程與類型系統
- RESTful Java Web Services(Second Edition)
- Babylon.js Essentials
- ASP.NET程序開發范例寶典
- Android應用開發深入學習實錄
- 大數據時代的企業升級之道(全3冊)
- Microsoft XNA 4.0 Game Development Cookbook
- Illustrator CS6中文版應用教程(第二版)