[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

When importing from CSV, why is MySQL raising a 'Data truncated' warning?

Posted on 2009-05-11
3
Medium Priority
?
687 Views
Last Modified: 2012-05-06
When running a simple SQL command to import some CSV data, I'm receiving warnings on a particular column on seemingly random rows:
Warning (Code 1265): Data truncated for column 'SubGroupNum' at row 2
Warning (Code 1265): Data truncated for column 'SubGroupNum' at row 3
Warning (Code 1265): Data truncated for column 'SubGroupNum' at row 5
Warning (Code 1265): Data truncated for column 'SubGroupNum' at row 6
Warning (Code 1265): Data truncated for column 'SubGroupNum' at row 8

Here is the schema of the DB:
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| IdxId       | double       | NO   |     | NULL    |       |
| YrGrpId     | double       | NO   |     | NULL    |       |
| GroupNum    | double       | NO   |     | NULL    |       |
| LineNum     | int(11)      | NO   |     | NULL    |       |
| LogicalMod  | int(11)      | YES  |     | NULL    |       |
| Application | varchar(255) | YES  |     | NULL    |       |
| SubGroupNum | double       | YES  |     | NULL    |       |
| SubCategory | varchar(2)   | YES  |     | NULL    |       |
| PTypeNum    | char(3)      | YES  |     | NULL    |       |
| IntchNum    | char(5)      | YES  |     | NULL    |       |
| AlphaExt    | char(2)      | YES  |     | NULL    |       |
| LRFlag      | char(1)      | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+

Any insight as to what I need to change?
load data local infile 'Idx_App.txt' into table `Idx_App`
fields terminated by ','
enclosed by ''''
lines terminated by '\r\n'
(IdxId, YrGrpId, GroupNum, LineNum, LogicalMod, Application, SubGroupNum, SubCategory, PTypeNum, IntchNum, AlphaExt, LRFlag)
;

Open in new window

Idx-App.txt
0
Comment
Question by:fluffyx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Expert Comment

by:bull_rider
ID: 24361078
What I observed is if teh subgroupname is not provided that row fails. Can you check the datatype or may be the column in the database is accepting NULL or blank values or not?
0
 
LVL 6

Accepted Solution

by:
BALMUKUND KESHAV earned 1000 total points
ID: 24361406
problem is where is subgroup has no data, and its showing like ,,,
if you have checked your subgroup fields type accepting null or 0,then if its varchar type then try to change your txt fields format like this
fields enclosed with " " sepereated with , and ensure where is no data it shows ""
then use this command

 load data local infile 'Idx_App.txt' into table `Idx_App`
fields terminated by ","
enclosed by ""
lines terminated by '\r\n'
(IdxId, YrGrpId, GroupNum, LineNum, LogicalMod, Application, SubGroupNum, SubCategory, PTypeNum, IntchNum, AlphaExt, LRFlag)

bm keshav

 
0
 

Author Closing Comment

by:fluffyx
ID: 31580376
That's causing it! Now comes the challenge of modifying the 80MB TXT file :-).
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question