I want to read a csv file which is separated by comma (,
) but want to ignore comma within the double quotes (""
). I want to store the result into a table.
Example:
abc,00.000.00.00,00:00:00:00:00:00,Sun Nov 01 00:00:00 EST 0000,Sun Nov 01 00:00:00 EST 0000,"Apple, Inc.",abcd-0000abc-a,abcd-abcd-a0000-00
Here I don't want to split on Apple, .
I know there exists csv reader in python and I can use it in plpython but that's slow considering millions of such strings! I would like a pure psql method!
答案 0 :(得分:1)
以下是使用CSV格式读取带外部表的CSV文件的示例。
CREATE EXTERNAL TABLE ext_expenses ( name text,
date date, amount float4, category text, desc1 text )
LOCATION ('gpfdist://etlhost-1:8081/*.txt',
'gpfdist://etlhost-2:8082/*.txt')
FORMAT 'CSV' ( DELIMITER ',' )
LOG ERRORS SEGMENT REJECT LIMIT 5;
这也取自Greenplum文档。