简体   繁体   English

使用带有列类型的 mongoimport 导入 CSV

[英]Import CSV using mongoimport with types of the column

Am using mongoimport with defined field type --columnsHaveTypes.我正在使用具有定义字段类型 --columnsHaveTypes 的 mongoimport。 When i import the file got an error当我导入文件时出错

Failed: type coercion failure in document #1 for column 'time', could not parse token '2020-09-08T09:41:19.693+0300' to type date>失败:在文档 #1 中为列“时间”键入强制失败,无法解析令牌“2020-09-08T09:41:19.693+0300”以键入日期>

i used the below command我使用了下面的命令

mongoimport --db main --collection data --type csv --columnsHaveTypes --fields="time.date(2006-01-02),duration.int32(),entry.string()" --file="path\\to\\test.csv" mongoimport --db main --collection data --type csv --columnsHaveTypes --fields="time.date(2006-01-02),duration.int32(),entry.string()" --file="path \\to\\test.csv"

2020-09-08T09:41:19.693+0300 is not standard representation of date/time so mongoimport cannot parse it. 2020-09-08T09:41:19.693+0300不是日期/时间的标准表示,因此 mongoimport 无法解析它。

https://tools.ietf.org/html/rfc3339#section-5.6 defines local offset as https://tools.ietf.org/html/rfc3339#section-5.6将本地偏移定义为

time-numoffset = ("+" / "-") time-hour ":" time-minute time-numoffset = ("+" / "-") time-hour ":" time-minute

Your string lacks a colon.您的字符串缺少冒号。 2020-09-08T09:41:19.693+03:00 will be parsed correctly. 2020-09-08T09:41:19.693+03:00将被正确解析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM