H2数据库CSVREAD未修剪报价

时间:2017-07-31 16:20:07

标签: csv h2 delimiter quote

我的输入文件在每个字段周围都有引号。

"1386568706","1","","","","DK","ME","LY PRECRT","","","A.D."

我想使用CSVREAD阅读这些字段。我尝试了以下选项。

insert into s_no_date
select convert(PI,bigint),
convert(ENT_CODE,int),
REPLACEMENT_PI,
EMN,
PNAME,
d,
er,
ert,
sd,
cg,
sdf
','fieldDelimiter=')

我收到了以下错误。

Caused by: java.lang.NumberFormatException: For input string: ""1578956447""
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:578)
    at java.lang.Long.parseLong(Long.java:631)
    at org.h2.value.Value.convertTo(Value.java:942)

尝试了另一种选择:

insert into s_no_date
select convert(PI,bigint),
convert(ENT_CODE,int),
REPLACEMENT_PI,
EMN,
PNAME,
d,
er,
ert,
sd,
cg,
sdf
')

错误:

Caused by: java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:592)
    at java.lang.Integer.parseInt(Integer.java:615)
    at org.h2.value.Value.convertTo(Value.java:940)

1 个答案:

答案 0 :(得分:0)

以下是有效的。我还必须将ENT_CODE的数据类型从int更改为varchar,因为它可以为空。我不得不以fieldDelimiter

来逃避引用
insert into s_no_date
select convert(PI,bigint),
ENT_CODE,
REPLACEMENT_PI,
EMN,
PNAME,
d,
er,
ert,
sd,
cg,
sdf
','fieldDelimiter=\"');