import csv 错误:时间戳类型的输入语法无效:""

huangapple go评论71阅读模式
英文:

import csv error: invalid input syntax for type timestamp: ""

问题

> 错误: 无效的时间戳类型输入语法: ""
? 上下文: 复制 User, 第2行, emailVerified列: ""

在Supabase中,所有记录的emailVerified字段都为空。CSV示例如下:

"id","name","email","emailVerified","image"    
"abc123","Guy Man","guyt@man.com","","https://pic.com"

我尝试编辑CSV并将NULL添加到emailVerified字段,但仍然出现相同的错误。我还尝试在PGAdmin的导入选项中添加Null。

然后,我尝试手动输入一条记录。我通过输入每个字段添加了上面的记录。我没有为emailVerified输入任何内容,它接受了。

如何避免这个问题?这是一个包含5条记录的测试表,我可以手动添加这些记录,但这不是一个理想的解决方案。如何让PgAdmin接受CSV中原样编写的记录?

英文:

I'm trying to import a CSV file that I exported from supabase using PGAdmin I keep getting this error:

> ERROR: invalid input syntax for type timestamp: ""
? CONTEXT: COPY User, line 2, column emailVerified: ""

In Supabase, the emailVerified field is empty for all records. The CSV example looks like this:

"id","name","email","emailVerified","image"    
"abc123","Guy Man","guyt@man.com","","https://pic.com"

I tried editing the CSV and added NULL to the emailVerified field but same error. I also tried adding Null to the import options in PGAdmin.

I then tried to manually enter a record. I added the one above by entering each field. I didn't enter anything for emailVerified and it accepted it.

How do I avoid this problem? This was a test table with 5 records in it, I can add these all manually, but this isn't an ideal solution. How do I get PgAdmin to accept the record as it was written in the CSV?

答案1

得分: 1

以下是翻译好的部分:

CSV格式中表示NULL的默认方式是完全空字符串。所以在你的情况下,看起来像这样:

"abc123","Guy Man","guyt@man.com",,"https://pic.com"

请注意第4个字段没有双引号。

要导入当前的数据,您需要在COPY命令中指定force_null ("emailVerified")。这告诉它即使在双引号内也要查找表示NULL的字符串。但据我所知,通过pgAdmin4 GUI方法没有办法构建这样的COPY命令。

所以你要么需要手动构建命令并在psql中运行它,要么编辑你的输入文件以省略空字段周围的双引号。

英文:

The default way to represent NULL in the CSV format is with a completely empty string. So in your case, that would look like:

> "abc123","Guy Man","guyt@man.com",,"https://pic.com"

Note the lack of double quotes for the 4th field.

To import the data as it currently is, you would specify force_null ("emailVerified") to the COPY command. That tells it to look for the NULL-signifying string even if it is within double quotes. But as far as I can tell, there is no way to construct such a COPY command via the pgAdmin4 GUI method.

So you either need to construct the command manually and run it in psql, or edit your input file to omit the double quotes around the null field.

huangapple
  • 本文由 发表于 2023年6月1日 04:17:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76376980.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定