如何将Excel文件(XLSX)导入到mongoDB [英] how to import excel file (XLSX) to mongoDB

查看:1359
本文介绍了如何将Excel文件(XLSX)导入到mongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组数据作为输入要以XLSX格式提供给MongoDB.我应该如何将Excel文件作为输入导入到MongoDB?

I have a set of data as input to be given to MongoDB in XLSX format. How am I supposed to import the Excel file as input to MongoDB?

是否有可用于将xlsx文件作为输入导入到MongoDB的插件?

Is there any plugin available to import xlsx files as input to MongoDB?

推荐答案

您不能将XLSX文件直接导入到MongoDB中.但是,使用Excel电子表格可以将其另存为CSV文件,然后使用mongoimport将其导入到MongoDB中.您可以在mongoimport 此处找到文档,但是无论如何,您都需要使用该命令运行应该类似于以下内容:

You cannot import an XLSX file into MongoDB directly. However, what you can do with an Excel spreadsheet is save it as a CSV file, then use mongoimport to import it into MongoDB. You can find the documentation for mongoimport here, but in any case, the command you need to run should look something like the following:

mongoimport --db myDb --collection myCollection --type csv --headerline --file /path/to/myfile.csv

在上面的命令中,--headerline标志指示文件中的第一行包含字段名称.您可以根据需要使用许多其他选项.这些在文档中突出显示.

In the command above, the --headerline flag indicates that the first line in your file contains the name of the fields. There are many other options you can use depending on your needs. These are highlighted in the documentation.

这篇关于如何将Excel文件(XLSX)导入到mongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆