当前位置:网站首页>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
边栏推荐
- Evolution of customer service hotline of dewu
- Battle Atlas: 12 scenarios detailing the requirements for container safety construction
- Toraw and markraw
- Mongodb meets spark (for integration)
- Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
- 2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
- 118. 杨辉三角
- 【日常训练】648. 单词替换
- Show the mathematical formula in El table
- [fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?
猜你喜欢

2022-7-6 Leetcode 977. Square of ordered array

如何让join跑得更快?

xshell连接服务器把密钥登陆改为密码登陆

Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
![[dark horse morning post] Huawei refutes rumors about](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours

118. Yanghui triangle

Final review notes of single chip microcomputer principle

Detr introduction

Evolution of customer service hotline of dewu
![Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]](/img/35/5224252624cc76f42cbd0fd5c81d8c.png)
Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]
随机推荐
Battle Atlas: 12 scenarios detailing the requirements for container safety construction
Introduce six open source protocols in detail (instructions for programmers)
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours
[high frequency interview questions] difficulty 2.5/5, simple combination of DFS trie template level application questions
2022-7-6 Leetcode 977. Square of ordered array
toRaw和markRaw
华为镜像地址
Use of polarscatter function in MATLAB
高等数学---第八章多元函数微分学1
cmake 学习使用笔记(一)
Scripy tutorial classic practice [New Concept English]
2022-7-7 Leetcode 844. Compare strings with backspace
Cinnamon taskbar speed
高等數學---第八章多元函數微分學1
Help tenants
Some principles of mongodb optimization
LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
566. Reshaping the matrix
存储过程的介绍与基本使用
QQ medicine, Tencent ticket