A
A
Artem2016-08-14 20:06:19
MySQL
Artem, 2016-08-14 20:06:19

Import to Mysql from csv. How to do?

Hello! I have such a problem. There is a file in csv format. The first column contains data from 1 column in the db. In the second - from 2 columns, respectively.
Unable to import to database. There, the data must be in quotes and on one line, separated by commas.
Rewriting is not an option. i have 170k rows.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Artem, 2016-08-14
@proudmore

As an option, rewrite with a regular expression, or look for something related to separators in mysql

V
Vladislav, 2016-08-14
@MrBikus

Take any CSV parser from github for your favorite programming language, write a small program that will do all this for you. All this will take 10 minutes.

T
ThunderCat, 2016-08-14
@ThunderCat Куратор тега MySQL

phpMyAdmin позволяет задать разделители и переносы / окончания строк вручную

I
ivanovnickolay, 2016-08-16
@ivanovnickolay

170 thousand lines. ?
From experience, I’ll say the parser algorithm in PHP has a chance to die or freeze.
I have a table with 160 thousand rows and 19 columns, the process hung up for 38-40 thousand lines, although the file was processed according to the proven algorithm blog.cinu.pl/2013/08/doctrine2-php-inserting-large...
try using LOAD DATA INFILE so it will be many times faster

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question