A
A
angelzzz2017-06-05 18:03:00
MySQL
angelzzz, 2017-06-05 18:03:00

How to load csv file with HTML tags in MySQL?

There is a store database.
The Description field contains html tags in the form: < >. Also, the data in this field contains tab characters.
First, I upload this table to excel using PHPexcel, change, add, edit, then save to csv. Then I use the code to insert back into the base:

TRUNCATE TABLE oc_product_description
LOAD DATA INFILE 'Z:\\home\\localhost\\www\\\xls\\some_excel_file - UTF8.csv' INTO TABLE oc_product_description FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES (product_id,name,description,meta_description)

The first problem: (resolved) to separate the fields, I replaced ";" in the windows settings to "|". Changed part of the code accordingly:
FIELDS TERMINATED BY '|'
Second problem: I don't know how to defeat tabs in the description field. Because of them, the data cannot be inserted normally. The first occurrence of a tab character jumps to the next entry.
LINES TERMINATED BY '\n'
What to do?
(I described the first problem, maybe this is the wrong decision on my part)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question