Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid column count in CSV input on line 1 Error

Tags:

php

mysql

csv

excel

I'm trying to get a ".csv" file onto an SQL database with phpMyAdmin. However, whenever I import it, I get the error: Invalid column count in CSV input on line 1. I've spent all day playing around with different options to try and get it to work but with no avail. There are exactly 47 columns in my .csv file. I have created 47 columns in my SQL table. The names however aren't exactly the same as the ones in the file. Whenever I import, it keeps giving me that error. Any help would be greatly appreciated! ~Carpetfizz One thing I thought might be causing the problem was that the first column isn't named anything in my excel document. Could this be causing an issue?

EDIT 12:30AM: phpMyAdmin is already the latest version available, via (apt-get install phpmyadmin) (phpmyadmin is already latest version)

Space in A1

Here is the .csv file, if that helps.

like image 767
Carpetfizz Avatar asked Apr 27 '13 03:04

Carpetfizz


People also ask

Why is my csv file invalid?

Verify that the CSV file is formatted the same way as our sample CSV file. Make sure the "Username" column has a header defined. Make sure the username field is not blank for any users. Make sure the delimiter used in your file is a comma.

Why is CSV not importing?

The most common CSV import errors include: The file size is too large - The CSV import tool of the program you're using might have a file size requirement. To reduce the file size, you can delete unnecessary data values, columns, and rows.


2 Answers

If your DB table already exists and you do NOT want to include all the table's columns in your CSV file, then when you run PHP Admin Import, you'll need fill in the Column Names field in the Format-Specific Options for CSV - Shown here at the bottom of the following screenshot.

In summary:

  • Choose a CSV file
  • Set the Format to CSV
  • Fill in the Column Names field with the names of the columns in your CSV
  • If your CSV file has the column names listed in row 1, set "Skip this number of queries (for SQL) or lines (for other formats), starting from the first one" to 1

enter image description here

like image 70
Daniel Flippance Avatar answered Oct 03 '22 07:10

Daniel Flippance


Fixed! I basically just selected "Import" without even making a table myself. phpMyAdmin created the table for me, with all the right column names, from the original document.

like image 31
Carpetfizz Avatar answered Oct 03 '22 06:10

Carpetfizz