当前位置:网站首页>mysql导入文件出现Data truncated for column ‘xxx’ at row 1的原因
mysql导入文件出现Data truncated for column ‘xxx’ at row 1的原因
2022-07-07 11:48:00 【全栈程序员站长】
mysql导入文件的时候很容易出现”Data truncated for column ‘xxx’ at row x”,其中字符串里的xxx和x是指具体的列和行数.
有时候,这是因为数据类型的不对应,或者字符串长度不够而造成的.
但是,经常出现row 1就报错,并且感觉它没什么不对的样子.
这往往是因为windows的回车换行”\r\n”作怪,下面的测试说明了这种情况.
我有一个train.csv的数据文件,我用python修改后保存为c.csv.
但是,我用相同的命令把它们导入到mysql时,train能导入,c却出错.
我把行结束符从”\n”换成”\r\n”后,导入成功.
用notepad打开这两个文件,会发现train根本没有换行,而c则有换行.
这说明train里只有”\n”,因此notepad无法识别到换行,而c里则是”\r\n”.
然而用python生成c.csv的时候,输出只有”\n”,这说明python在win下会自动把”\n”变成”\r\n”.
还有一点是,除了notepad外的大部分win下的编辑器,都既能识别”\n”又能识别”\r\n”.
因此只有用notepad才能知道到底是”\n”还是”\r\n”,或者用winHex等工具直接看ascii码.
最后的结论是,注意这个数据文件的换行到底是”\n”还是”\r\n”.
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/113289.html原文链接:https://javaforall.cn
边栏推荐
- 如何让join跑得更快?
- 云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
- What are the principles for distinguishing the security objectives and implementation methods that cloud computing security expansion requires to focus on?
- Problems that cannot be accessed in MySQL LAN
- Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)
- ESP32 ① 编译环境
- 2022-7-6 Leetcode 977.有序数组的平方
- Cinnamon taskbar speed
- Mongodb command summary
- 【堡垒机】云堡垒机和普通堡垒机的区别是什么?
猜你喜欢
1、深拷贝 2、call apply bind 3、for of for in 区别
QQ的药,腾讯的票
xshell连接服务器把密钥登陆改为密码登陆
Thread pool reject policy best practices
2022-7-6 beginner redis (I) download, install and run redis under Linux
Navicat run SQL file import data incomplete or import failed
2022-7-7 Leetcode 844.比较含退格的字符串
Detr introduction
Cmake learning and use notes (1)
2022-7-7 Leetcode 844. Compare strings with backspace
随机推荐
[etc.] what are the security objectives and implementation methods that cloud computing security expansion requires to focus on?
2022-7-6 Leetcode 977. Square of ordered array
mysql 局域网内访问不到的问题
1. Deep copy 2. Call apply bind 3. For of in differences
Redis只能做缓存?太out了!
Milkdown control icon
Dry goods | summarize the linkage use of those vulnerability tools
QQ medicine, Tencent ticket
2022-7-6 beginner redis (I) download, install and run redis under Linux
566. 重塑矩阵
How to make join run faster?
Ikvm of toolbox Net project new progress
TPG x AIDU | AI leading talent recruitment plan in progress!
交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)
一文读懂数仓中的pg_stat
【日常训练--腾讯精选50】231. 2 的幂
2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out
2022-7-6 Leetcode 977.有序数组的平方
. Net core about redis pipeline and transactions
118. Yanghui triangle