带有双引号的 MySQL 加载数据 infile 字段错误 [英] error with MySQL load data infile field with double quotes

查看:56
本文介绍了带有双引号的 MySQL 加载数据 infile 字段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的 .csv 文件数据:

I have .csv file data like this:

"UPRR 38 PAN AM "M"","1"

我使用以下命令将数据加载到表中,该命令有两列(ab).

and I loaded data into table using below command which is having two columns (a and b).

LOAD DATA LOCAL INFILE 'E:\monthly_data.csv'
INTO TABLE test_data_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';

但是当我选择表格时,它给出了如下所示的意外结果.

But when I select table, it's giving unexpected results which is shown below.

a 包含:

UPRR 38 PAN AM "M","1

... 并且 b 是 NULL.

... and b is NULL.

谢谢

推荐答案

您可以替换文件中所有双引号"的实例

You can replace all the instances of "Double quote double quote" in your file

要么 A. 打开文件并找到替换它们或 B. 制作一个脚本来打开文件并替换将其弄乱的额外引用

either A. open the files and find replace them or B. make a script to open the files and replace the extra quote that is messing it up

这篇关于带有双引号的 MySQL 加载数据 infile 字段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆