dongliyu3278 2014-02-14 13:55
浏览 238
已采纳

mySql导入中的escape char问题

I have a small issue importing a csv file into mysql. I am using csv file with loaddata as import.

The escape char that the supplier of the csv file have chosen to use is : ¤ What ever I try to enter when importing the csv file ends up with this error:

LOAD DATA LOCAL INFILE 'C:\\xampp\\tmp\\php1E14.tmp' INTO TABLE `TableName` FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\¤' LINES TERMINATED BY '
' 

MySQL returned: Documentation

#1083 - Field separator argument is not what is expected; check the manual 

Any ideas on how to fix this issue, and please not just have the supplier using another escape char.

  • 写回答

1条回答 默认 最新

  • du7999 2014-02-14 14:44
    关注

    Why are you prefixing your escape character with a literal backslash? Indeed, as documented under LOAD DATA INFILE Syntax:

    If not empty, the FIELDS [OPTIONALLY] ENCLOSED BY and FIELDS ESCAPED BY values must be a single character.

    Therefore:

    LOAD DATA LOCAL INFILE 'C:\\xampp\\tmp\\php1E14.tmp'
        INTO TABLE `TableName`
        FIELDS
            TERMINATED BY ';'
            ENCLOSED BY '"'
            ESCAPED BY '¤'
        LINES
            TERMINATED BY '
    '
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大