如何定义delimeter来导入mongodb [英] How to define delimeter to import mongodb

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

问题描述

我有一个数据集合,它由 | 字符分隔。我要将数据集合添加到 mongodb 。所以我需要通过 | 字符分隔数据。



以前,我通过以下命令成功导入了 csv 文件。

  $ mongoimport -d mydb -c things --type csv --file locations.csv --headerline 


解决方案

mongoimport JSON,CSV(逗号分隔值)或TSV(制表符分隔值)。 | 字符不是CSV或TSV的有效分隔符,因此您需要更改输入文件 | 或标签,并相应地指定 - type


I have a data collection, which is separated by | character. I am going to add the data collection to mongodb. So I need to separate data through | character. how my mongoimport command looks like?

Previously, I'm successfully import csv file through the following command.

$ mongoimport -d mydb -c things --type csv --file locations.csv --headerline

解决方案

mongoimport supports either JSON, CSV (comma separated values) or TSV (tab separated values). The | character is not a valid delimiter for either CSV or TSV, so you will need to change your input files' | to , or a tab, and specify --type accordingly.

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

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