MySQL is adding characters to my data

388 Views Asked by At

I have a Table in MySQL and I am adding data to it from a csv file

My code is:

LOAD DATA LOCAL INFILE 'C:/myaddress/file.csv'
INTO TABLE db.mytable
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
(`Currency`,`field2`,`field3`)

This loads fine except for the first row I add.

I'm adding a USD but when I do a query it imports it as USD. This only happens for the first row. Anybody knows why this happens?

Solution: This is an encoding issue, so to solve it, here are two options

1.- Encode the file differently

2.- Add a dummy line and use IGNORE 1 LINES

1

There are 1 best solutions below

1
On BEST ANSWER

I think this is something related with your csv. It has been encoded with UTF-8 BOM in ISO-8859-1 (spanish?).

If you are using a editor like Notepad++ open your csv and select from the top menu -> Encoding -> utf-8 without DOM , save and try again.