I'm using COPY INTO
to bulk insert some data into MonetDB. The csv that I'm copying from has some special characters like \
in some string fields and it broke the insertion. The error that I got is:
我正在使用COPY INTO将一些数据批量插入MonetDB。我正在复制的csv在某些字符串字段中有一些特殊字符,如\,它打破了插入。我得到的错误是:
Failed to import table line 1 field 11 'clob' expected in 'data here'
无法导入“数据在此处”中预期的表格第1行字段11“clob”
and when I replace \
with /
it is working fine, I think the problem related to Java because \
is using as escape character but I'm not sure!
当我用/替换它工作正常时,我认为问题与Java有关,因为\是用作转义字符,但我不确定!
this is the command I used for bulk load :
这是我用于批量加载的命令:
COPY INTO line : copy into dbtest.dbo.table3 from '/home/etltest/out.csv' using delimiters ';','\n','"';
and this is a sample row :
这是一个示例行:
"452475";"0047748";"002";"2014-01-01 00:16:00.000";"2";"2014-01-01 00:16:16.090";"1";"1";"0";"testfile.xml";"~/uploads/Su/F0047748\2014\1";"3d67502e-94ed-4e3d";"2014-01-01 00:15:25.283"
I found a work around which use REPLACE
function in the SQL to replace \
with /
but this is too heavy processing function when handling millions of rows
我找到了一个解决方法,在SQL中使用REPLACE函数替换\ with /但处理数百万行时处理功能太重了
Why is this happening and is there any way rather than replace the \
?
为什么会发生这种情况并且有什么办法而不是取代\?
1 个解决方案
#1
0
You're right, the '\' is an escape character. To fix the import error, you need to double it. Replace all '\' occurences in your csv file with '\'.
你是对的,'\'是逃脱角色。要修复导入错误,您需要将其加倍。用'\'替换csv文件中的所有'\'出现。
Doing this with REPLACE SQL function will be costly. If possible, double the '\'in your CSV file directly, or change the tool that generates the CSV file to take care of this.
使用REPLACE SQL函数执行此操作将非常昂贵。如果可能,请直接将CSV文件中的“\”加倍,或更改生成CSV文件的工具来处理此问题。
#1
0
You're right, the '\' is an escape character. To fix the import error, you need to double it. Replace all '\' occurences in your csv file with '\'.
你是对的,'\'是逃脱角色。要修复导入错误,您需要将其加倍。用'\'替换csv文件中的所有'\'出现。
Doing this with REPLACE SQL function will be costly. If possible, double the '\'in your CSV file directly, or change the tool that generates the CSV file to take care of this.
使用REPLACE SQL函数执行此操作将非常昂贵。如果可能,请直接将CSV文件中的“\”加倍,或更改生成CSV文件的工具来处理此问题。