将csv文件中存在的NULL值复制到postgres [英] Copy NULL values present in csv file to postgres
本文介绍了将csv文件中存在的NULL值复制到postgres的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下格式的csv文件(y.csv):
's' 10','1999-12-12'
'b','99 -10-10 BC','1-10-10 BC'
'c','NULL','NULL'
我有几个NULL值'。
我试图将csv文件复制到postgres。为此,我创建了一个表:
创建表r(id字符变化(255),timebegin日期,timeend日期) ;
现在我试图使用命令
$将上面的.csv文件复制到postgres b$ b
copy r从'/home/y.csv'delimiter','csv;
/ pre>
错误:无效的输入语法类型date:'NULL'
CONTEXT:COPY r,第1行,列timebegin:'NULL'
这样做时,我得到一个错误NULL。
解决方案有没有尝试过?
copy r从'/home/y.csv'delimiter','csv WITH NULL AS'null';
I have csv file (y.csv) in the folowing format:
's', '1999-10-10', '1999-12-12' 'b', '99-10-10 BC', '1-10-10 BC' 'c', 'NULL', 'NULL'
I have a few NULL values (for date) in it which I have indicated through the string 'NULL'.
I am trying to copy the csv file into postgres. For doing so I have created a table:
create table r (id character varying(255), timebegin date, timeend date);
Now I am trying to copy the above .csv file into postgres using the command
copy r from '/home/y.csv' delimiter ',' csv; ERROR: invalid input syntax for type date: " 'NULL'" CONTEXT: COPY r, line 1, column timebegin: " 'NULL'"
On doing so I am getting an error with NULL. Can someone please help me figure out the error and correct it.
解决方案Have you tried it?
copy r from '/home/y.csv' delimiter ',' csv WITH NULL AS 'null';
这篇关于将csv文件中存在的NULL值复制到postgres的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文