创建一个表:
CREATE TABLE num (
id serial NOT NULL ,
adsh VARCHAR(20) NOT NULL,
tag VARCHAR(256) NOT NULL,
version VARCHAR(20) NOT NULL,
coreg VARCHAR(256),
ddate date NOT NULL,
qtrs DECIMAL(8) NOT NULL,
uom VARCHAR(20),
value DECIMAL(28,4),
footnote VARCHAR(512)
);
我想将sample.txt
数据导入num
表中:
adsh tag version coreg ddate qtrs uom value footnote
0001213900-20-033598 DueToAsiyaCommunicationsSapiDeC.v.Current 0001213900-20-033598 20191231 0 USD
0001213900-20-033598 DueToDinarZuzLLC 0001213900-20-033598 20200630 0 USD 178000.0000 Due to the April 6, 2020 180 days Loan Agreement with the Company to borrow up to $250 at an annual interest rate of nine percent (9.0%) ("the second "Dinar Zuz Note").
0001213900-20-033598 DueToNextCalaCurrent 0001213900-20-033598 20181231 0 USD -14000.0000
0001213900-20-033598 DueToNextCalaCurrent 0001213900-20-033598 20191231 0 USD
将数据sample.txt
导入表中的命令:
COPY num(adsh,tag,version,coreg,ddate,qtrs,uom,value,footnote)
FROM 'sample.txt'
DELIMITER E'\t'
CSV HEADER;
它遇到一个错误:
ERROR: unterminated CSV quoted field
CONTEXT: COPY num, line 6: "0001213900-20-033598 DueToDinarZuzLLC 0001213900-20-033598 20200630 0 USD 178000.0000 Due to the Ap..."
请在不编辑原始数据的情况下修复它。
"
是 CSV 文件中的默认引号字符。它引用包含分隔符且不能不平衡的字段使用该
QUOTE
选项指定不同的引号字符:这假定 BEL 字符 (ASCII 7) 未出现在您的数据中。