merge multiple fields of csv file while running mysqlimport command
0
votes
1
answer
265
views
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 by Anurag Sharma
(101 rep)
Apr 16, 2015, 07:34 AM
Last activity: May 21, 2025, 08:05 PM
Last activity: May 21, 2025, 08:05 PM