0

I have a mysql table like this

+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| roll_no | varchar(50) | NO | MUL | NULL | |
| marks | varchar(100) | YES | | NULL | |
| academy | varchar(100) | YES | | NULL | |
+----------------+--------------+------+-----+---------+----------------+

the marks column can have multiple numbers separated by comma like this

45,67,78,80, # First Example
34,56, # Second Example

I have to run mysqlimport command such that the fields after the first fields till second-last fields should merge into marks column

I tried something like this

mysqlimport --fields-terminated-by=, --columns='roll_no, marks, academy' --ignore --local -u root -pxxxx result results.csv

But extra fields (after 3rd one) gets truncated. How to handle such scenarios where the csv fields are dynamic

asked Apr 16, 2015 at 7:34
1
  • Running on a unix-like system? Why not use some commands like cut or awk first? Commented Apr 16, 2015 at 7:50

1 Answer 1

0

Because it is a CSV file (Comma Separated Values), it thinks that the each of the marks is a different field. Your initial export should either separate values by a different char, like "#", or quot the values bu ".

answered Apr 16, 2015 at 15:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.