Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySQL 1262 Error

Posted on 2014-07-23
4
Medium Priority
?
2,436 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 2000 total points
ID: 40214785
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
ID: 40214816
Enya,A Day Without Rain,Processional Songs

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

Expert Comment

by:SStory
ID: 40215182
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 111

Expert Comment

by:Ray Paseur
ID: 40219562
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

782 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