Solved

MySQL 1262 Error

Posted on 2014-07-23
4
1,839 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
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 109

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

772 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