如何在mongodb中导入csv文件 [英] how to import csv file in mongodb

查看:594
本文介绍了如何在mongodb中导入csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含以下数据的csv文件,并想将其导入mongodb

I have a csv file containing following data and want to import it in mongodb

ID;"AdmissionID";"SeatNo";"RegistrationNo";"ResultDate";"ResultStatusId"
1;12;"2323";"23";07-05-2013;1
2;23;"35";"32";10-05-2013;5

此数据将导入到mongodb 2.2.我正在使用以下命令:

this data is to be imported to mongodb 2.2. I'm using following command:

mongoimport -d test -c exam --type csv --headerline <f:\exam.csv

使用时出现以下错误

SyntaxError: missing ; before statement (shell):1

请帮助我找出错误

推荐答案

这应该很容易做到.更多此处.

This should do the trick easily. More HERE.

 mongoimport -d mydb -c collectionName --type csv --file myfile.csv --headerline

您的问题是<f:\exam.csv位,该位不能通过其外观正确地转义

Your problem is the <f:\exam.csv bit, which is not properly escaped by the way it looks

> --headerline
> If using "--type csv" or "--type tsv," use the first line as field names. Otherwise, mongoimport will import the first line as a distinct
> document.

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

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