嗨,我知道已经问了很多问题,但这有点不同。我有包含数百万条记录的 csv 文件。我尝试使用以下命令从 csv 复制到我的表,即
copy "client_data" from '/home/mike/Desktop/client_data.txt' with delimiter ',' CSV;
但是问题出现了,因为 csv 中的数据状态不一致,即
以下几行想要魅力
12/12/12 20:17:35,304000000,"123","1"
12/12/12 20:17:36,311000000,"123","2"
12/12/12 20:17:36,814000000,"123","2"
12/12/12 20:17:36,814000000,"123","2"
12/12/12 20:17:37,317000000,"123",".1"
12/12/12 20:17:38,863000000,"123","TS"
12/12/12 20:17:39,835000000,"123","2"
12/12/12 20:17:40,337000000,"123","1"
但数百行有点像
12/12/12 20:20:03,790000000,"123","1
{'""}__{""'} /""'\
( $AMZA./)@FRIDI
{__}""'{__} /) (\. ,,DON,,"
12/12/12 20:20:30,501000000,"123","INAM NIKALTA NHE HE KITNE SAWALO K JAWB DAY
/G\A\,':/\,':/S\K,':\"
12/12/12 20:22:55,928000000,"123","PAKISTAN KI BUNYAAD
2=QUAID-E-AZAM"
12/12/12 20:22:56,431000000,"123","QUIED E AZAM
MOHAMMAD ALI JINNAH
[KFK FEROZ]"
由于换行符、逗号、无效字符等原因,哪些是不可解析的。有没有办法解析这些并以有效的方式将数据加载到 postgres 表中?
下面是表结构
create table "client_data" (
date_stamp text,
points bigint,
msisdn character varying(13),
data text
)
with (OIDS = false);
alter table "client_data" owner to postgres;