使用自带的mongoimport.exe导入test.csv文件(测试内容如下):
name,pass
test1,ztj"ile0
test2,"audreyhepburn"
test3,Xiaoya”””oge521
test4,""520xiangbin
问题:
导入后使用find({name:/^test/})
查询,发现pass字段全部显示错误(和csv中原值完全不同,显示为空值或者只有一半文本等)——请问MongoDB如何正确插入带双引号的文本记录??
无论是逐条insert还是批量import都无法插入带双引号的记录,即使使用“\”转义也不行,求大神!
According to CSV standards:
In the examples you gave,
test1
和test4
are all illegal. Although I have not confirmed that MongoDB parses CSV in strict accordance with RFC 4180 standards, there must be a big problem with your file format.Therefore, it is recommended to use a tool to standardize your CSV file before importing it into the database. I don’t know how large your data volume is, but this is just simple text processing, and the time consumption should be acceptable.
The following is a solution. Although it is not perfect, it should be suitable for most situations:
https://tools.ietf.org/html/rfc4180