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.
Related
I am trying to figure out why MYSQL isn't working as expected.
I imported my data from a CSV into a table called Products, which is shown in the screenshot. It's a small table of just ID and Name.
But when I run the where clause, finding out where the Name = 'SMS', it returns nothing? I don't understand what the issue is.
My CSV contents in Notepad++ is shown below:
This is what I used to load in my CSV, if there are any errors here.
Could you share your csv file content?
It's happened to me too before, and the problem is because there's some blank space in the data in csv file.
So maybe you could parse first your csv file data (remove the "not needed" blank space) before import it to database
This is often caused by spaces or look-alike characters. If caused by spaces or invisible characters at the beginning/end, you can try:
where name like '%SMS%'
You can then make this more general:
where name like '%S%M%S%'
When you get a match, you'll need to do more investigate to find the actual cause.
I am trying to import a csv file into MySQL 5.6 using Workbench 6.3, using the Table Data Import wizard. I had a few issues with illegal characters which I fixed by doing a search and replace on the headers in excel, but now I am getting the following error -
DBError: ("Incorrect column name ''", 1166)
ERROR: Import data file: ("Incorrect column name ''", 1166)
When I am trying to import it, it seems like MySQL thinks there's a column where there isn't one -
This is what I suspect is causing the issue, but unchecking it doesn't help.
In the raw csv file, the headers column, it lookes like
...Quantity_Needed, Part_Number,.
Is it the last comma after Part_Number that is making MySQL do this? In the errors before it gave me the column name that was problematic but with this I don't know what to fix.
Edit: Fixed it. Tried re-exporting again without the second duplicate column from the get go instead of trying to fix it, and it worked. I'm thinking maybe there was some bad data in that column or something.
When I export the data from excel as a CSV format it encapsulates some data in double quotes.
E.g.
8" becomes "8""". And I believe this operation is trying to get the database to understand the inside quote later on.
but for single quote 8', it keeps the same and this causes problem(see the pic below) while I am importing the csv.
Why not quoting the 8' into "8'" too?
8' becomes ' while importing, while "8'" will result in 8' And not quoting single quote leads some data loss.
question related:
what does quotechar mean in mysql while importing data?
Excel adds extra quotes on CSV export
After doing so many experiments, I finally found a pretty close answer.
Conclusion first:
It is Mysql Workbench's problem. Its import wizard works badly. I test under Navicat for every test data, and Navicat get all things right.
Single quote can caused unexpected behavior.
Test:
By default, Mysql workbench import wizard takes the first row value as column name, while in Navicat, I can configure that.
(All tests files are excel-exported csv utf8 encoding.)
test1:
e.g.: 8'(only 1 record), without column name.
Mysql: Pop out some unknown error and whatever configuration you change, can't get the original data.
Navicat:works fine.
test2:
e.g.: 8' , only 1 record with column name or have extra records without column name
Mysql: Can handle single quote properly.
Navicat: No problem.
test3:
If single quote exists, for most situation import wizard can't handle double quotes well.
e.g.: Single quote data comes before double quotes data.
Mysql: Fails totally.
Navicat: No problem.
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 have an access DB. I exported tables to xlsx. Then I saved as .ods using openOffice
because I found out that phpmyadmin-mysql no longer supports excel files. I have my mySQL database formated exactly as it should to accept the data. I import and everything seems fine except one little detail.
In some fields, the value is NULL instead of the value it should have according to the .ods file. Some rows show the same value for that field correctly, some show NULL.
Also, the "faulty" rows have some fields that show the value 0 for fields that where empty in the imported file (instead of NULL). Default value for those fields in mySQL is NULL. Each row has many fields like that and all of the same data type (tinyint). Some appear correctly NULL and some have the value 0....
I can't see a pattern on all these.
Any help is appreciated.
Check to see that imported strings have ("") quotes and NULL do not and that all are separated appropriately, usually a "," comma with the record/row delimited by ";" semicolon. Best way to check what the MySQL is looking for is to export some existing data to the same format and check it against what you are trying to import. One little missed quote and the deal is off. Be consistent in the use of either double " quotes or single ' quotes. also the ` character is not used as I think. If you are "squishing" your data through an application that applies "smart quotes" like MS word does or "Open Office??' this too can cause issues. Add the word NULL either inside or without quotes in your csv import where values appropriate.