Solved

MySQL 1262 Error

Posted on 2014-07-23
4
1,696 Views
Last Modified: 2014-07-25
Hi,

I get this error when I import a CSV.

Warning (1262): Row 1 was truncated; it contained more data than there were input columns */

See attached screenshot for row 1

See attached screenshot of my Structure

Also, what is the best collation to use?
Row-1.png
Structure.png
0
Comment
Question by:Computer Guy
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
Comment Utility
What is the delimiter set to? If it were a space that would cause the problem. If it is a comma, why don't you show part of the CSV?  If the fields have spaces longer than 50 they could be truncating inside, but it sounds like it is getting more columns that in your database which leads me to suspect the delimiter is a space.

Sample below from link below that.
LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field1, filed2, field3); 

Open in new window

(source: http://support.modwest.com/content/6/253/en/how-do-i-import-delimited-data-into-mysql.html)
0
 
LVL 3

Author Comment

by:Computer Guy
Comment Utility
Enya,A Day Without Rain,Processional Songs

See screen shot of how I import it.
data.png
0
 
LVL 25

Expert Comment

by:SStory
Comment Utility
I wonder if the AUTO_INCREMENT column is throwing you off.
Does it work if there is an ID in front of each.
1,text,text,text

Test that. If so you somehow need to ignore the first field. Some one on the web suggested putting @dummy as field 1 so it will get ignored. I haven't tried that.

Or if you do it my way from the TSQL line and name your fields, skipping the ID field (field 1) it may work that way.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Do you have PHP available?  If so, PHP can read the CSV file into an array with fgetcsv(), allowing for a variety of field delimiters.  The PHP code to take these arrays and create INSERT queries is pretty standard stuff.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now