Screenshot with error message
I am trying to import a csv file containing 22000 rows into a mysql database. But after some 2000 records its showing the error "Invalid column count in CSV input on line 2369."
It might not be because of the line that you had shown.
It might be because some of the names in some other lines might have a " ' " in between the names.
If you remove that everything would pass.
You might want to use text editors to edit that and remove the " ' ".
Thanks!
Related
Ok so I am trying to import data from a CSV file into mySQL database table. The table is called serial_code, however when I try to upload the CSV file I have an error message. I have tried taking the column names out, also adding NULL to the last column EngineSerialCode and I have also viewed the CSV in a text editor and it shows the columns correctly with , comma.
Invalid column count in CSV input on line 1.
Version of phpMyAdmin and mySQL
Database Fields
CSV Fields I want to import
Ok so I found the issue and it was quite frustrating. I had a serial code in my data that had a "," comma instead of a "-". Also I noticed that my CSV file EngineSerialCode was placed in column E and not D as I only have 4 columns in my database. From the image column C is overlapping column D hence my mistake.
I have a file of 700 000 rows and 90 columns and I had converted it to csv to upload it (using qualifier: "). The import worked but when I look at the table in SQL I see few text has moved to the next column.
In the actual file there is column called Comments and it has all type of characters(like *,|,| etc). Can this be the reason?
I tried doing the same import from .xlsb but it throws an error:
Failed to start
project(Microsoft.DataTransformationServices.VsIntegration)
If your fields have the same characters s the separator then of course the whole thing will break.
If you create the CSV with , as the separator and quotes (") around the fields, you should be able to handle it in SSIS using these instructions by adding " as the text qualifier.
I haven't tested this myself, but I would assume it works just fine.
I'm currently playing around with phpMyAdmin and I have encountered a problem. When importing my CSV into phpMyAdmin it's rounding the numbers. I have set the column to be a float and the column in Excel to be a Number (Also tried text/General) to no avail. Has anyone else encountered this issue and found a viable work-around?
A second question, is it possible for me to upload the CSV file so that it matches the column names in phpMyAdmin to Excel column names and enters the data in the correct column?
Your file should be look like this(decimal fields are of general type):
xlssheet
Save as CSV. File will be probably saved with ; separated
This is for new table:
Open phpMyAdmin, choose your database, click to import and select file to upload
Change format to CSV if there is not selected
Change in format specific options - columns separated with: ;
Be sure that checkbox (The first line of the file contains the table column names (if this is unchecked, the first line will become part of the data)) is SELECTED
Click Go
New table will be created with the structure according to the forst line in CSV.
This is for existing table:
Open phpMyAdmin, choose your database, CHOOSE YOUR TABLE which match the structure of imported file, click to import and select file to upload
Change format to CSV if there is not selected
Change in format specific options - columns separated with: ;
Change skip number of queries to 1 (this will skip the first line with column names)
Click Go
Selected table wich has the same structure as CSV will be updated and rows in CSV inserted.
// connecting dB
$mysqli = new mysqli('localhost','root','','testdB');
// opening csv
$fp = fopen('data.csv','r');
// creating a blank string to store values of fields of first row, to be used in query
$col_ins = '';
// creating a blank string to store values of fields after first row, to be used in query
$data_ins = '';
// read first line and get the name of fields
$data = fgetcsv($fp);
for($field=0;$field< count($data);$field++){
$col_ins = "'" . $col[$field] . "' , " . $col_ins;
}
// reading next lines and insert into dB
while($data=fgetcsv($fp)){
for($field=0;$field<count($data);$field++){
$data_ins = "'" . $data[$field] . "' , " . $data_ins;
}
$query = "INSERT INTO `table_name` (".$col_ins.") VALUES(".$data_ins.")";
$mysqli->query($query);
}
echo 'Imported...';
I've had the same issue.
Solved changing the separator between the integer part and the decimal part from comma to point.
i.e.
365,40 to 365.40
That worked for me.
I am trying to import a csv file into my mysql database using phpmyadmin but keep getting errors.
Here is how the csv looks:
Then I import like this:
And get the error: "Invalid parameter for CSV import: Fields enclosed by". I have tried to put the columns in quotes " or put a semicolon after each column, but keep getting errors.
Yeah, you have an extra field in there. For instance, with your example line of:
itemId,date,description,amount
,1,2/13/2013,Fabrics,44
the date maps to "description" because of the leading comma, which basically gives an empty (or null, depending on how the import is handled) value to itemId, which doesn't seem to be what you want. Where'd that extra comma come from -- was this an export from some program?
Also, in this case you don't have anything enclosing the fields so you should just be able to leave that value empty, which seems to have worked for you once you got the column count corrected.
I had to remove the first line of the csv (containing the column names) and that solved the issue. Everything got imported properly.
Note, the date field needed reformatting to match SQL's date format yyyy-mm-dd.
I get an invalid column count error while trying to import from a ; delimited CSV to MySQL via phpMyadmin. The error is possibly caused by the ; signs in the HTML text such as é. What should I do?
The records contained <pre> texts in coding-related articles, so I had to remove [CR] and [LF] chars (they were interpreted as new lines => new record), plus I had to replace ; in html entities with something else, so now column count matches and the import was successful. Converting back the replace text to ; everything works now.