Postgres中未终止的CSV引用字段 [英] unterminated CSV quoted field in Postgres

查看:1177
本文介绍了Postgres中未终止的CSV引用字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用copy命令将一些数据插入表中:

I'm trying to insert some data into my table using the copy command :

从'/tmp/otype_fdw.csv复制otype_cstore 'delimiter';'quote''csv;

我有这个答案:

错误:CSV引号结尾的字段

我的CSV文件中有一行问题:

There is the line in my CSV file where I have the problem :

533696; PoG; -251658240; from id GSW C;

这是唯一的双引号,但我无法删除,所以您对我有什么建议吗?

This is the only line a double quote and I can't remove it, so do you have some advice for me ?

谢谢预先

推荐答案

如果csv中有这样的行:

If you have lines like this in your csv:

533696;PoG;-251658240;from id GSW C";

这实际上意味着/显示字段没有被引用,只要字段中没有分隔符,这仍然是完全有效的csv。

this actually means/shows the fields are not quoted, which is still perfectly valid csv as long as there are no seperators inside the fields.

解析器应告知未引用字段。

In this case the parser should be told the fields are not quoted.

因此,与其使用 quote''(实际上是告诉解析器字段 以及引起错误的原因),您应该使用 quote'none'之类的东西,或者将quote参数省去(我不知道Postgres,因此我无法给您确切的选择)。

So, instead of using quote '"' (which is actually telling the parser the fields are quoted and why you get the error), you should use something like quote 'none', or leave the quote parameter out (I don't know Postgres, so I can't give you the exact option to do this).

好吧,我做了快速查找参数。看来确实没有关闭报价的选项。剩下的唯一选择是提供一个在数据中永远不会使用的引号字符。

Ok, I did a quick lookup of the parameters. It looks like there is not really an option to turn quoting off. The only option left would be to provide a quote character that is never used in the data.

quote E'\b'(退格键)似乎可以正常工作

这篇关于Postgres中未终止的CSV引用字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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