LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-23-2017, 09:14 PM   #1
Glenn D.
Member
 
Registered: May 2009
Location: ACT - Australia
Distribution: Opensuse x86_64 (Latest)
Posts: 132

Rep: Reputation: 26
need help with mysqlimport importing data problem


Hello,
I need help with mysqlimport importing data problem.

data loaded into first field only ,it should go across fields.

How is that done ?
Thanks
--Glenn

import data example
##
I85,Gleeson,John William
I86,Gleeson,Peter Graham
I87,McRae,Heather Joy
I88,Chambers,Judith Ann
I89,Chambers,Helen Margaret
I90,Chambers,Elizabeth Joyce
I91,Haberecht,Robert Paul
I92,Haberecht,Susan Gai
I93,Haberecht,John Graham
I94,Haberecht,Robyn Elizabeth
I95,Haberecht,Cathryn Ann
I96,Haberecht,Wendy Louise
I97,Taylor,Neil
I98,Taylor,David Neil
.
.

##
drop table people;
create table people (
INDIID varchar(30) ,
Surname varchar(30) ,
Given varchar(30) ,
Sex varchar(30) ,
BirDate varchar(30) ,
BirPlace varchar(30) ,
DeaDate varchar(30) ,
DeaPlace varchar(30)
);

MariaDB [test]> create table people (
-> INDIID varchar(30) ,
-> Surname varchar(30) ,
-> Given varchar(30) ,
-> Sex varchar(30) ,
-> BirDate varchar(30) ,
-> BirPlace varchar(30) ,
-> DeaDate varchar(30) ,
-> DeaPlace varchar(30)
-> );
Query OK, 0 rows affected (0.09 sec)

MariaDB [test]>

# mysqlimport --local test people.csv
test.people: Records: 890 Deleted: 0 Skipped: 0 Warnings: 7120

MariaDB [test]> create table people (
-> INDIID varchar(30) ,
-> Surname varchar(30) ,
-> Given varchar(30) ,
-> Sex varchar(30) ,
-> BirDate varchar(30) ,
-> BirPlace varchar(30) ,
-> DeaDate varchar(30) ,
-> DeaPlace varchar(30)
-> );
Query OK, 0 rows affected (0.08 sec)

MariaDB [test]> exit;
Bye

mysqlimport --ignore-lines=1 --fields-terminated-by=,--columns='INDIID,Surname,Given,Sex,BirDate,BirPlace,DeaDate,DeaPlace' --local -u root -p Database /path/to/csvfile/TableName.csv

#
MariaDB [test]> select INDIID from people;
+--------------------------------+
| INDIID |
+--------------------------------+
| I85,Gleeson,John William,M,1 A |
| I86,Gleeson,Peter Graham,M,17 |
|7,McRae,Heather Joy,F,,,,
| I88,Chambers,Judith Ann,F,10 J |
| I89,Chambers,Helen Margaret,F, |
| I90,Chambers,Elizabeth Joyce,F |
| I91,Haberecht,Robert Paul,M,,, |
| I92,Haberecht,Susan Gai,F,28 O |
| I93,Haberecht,John Graham,M,29 |
| I94,Haberecht,Robyn Elizabeth, |
| I95,Haberecht,Cathryn Ann,F,31 |
| I96,Haberecht,Wendy Louise,F,8 |
|or,Neil,M,,,,
| I98,Taylor,David Neil,M,5 Feb |
 
Old 05-23-2017, 09:40 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
The following works to import .csv files into MySQL. Don't know about MariaDB:
Code:
mysql> load data local infile '/path/to/filename.csv' into table tablename fields terminated by ',' lines terminated by '\n';
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Outlook data file to Evolution gurupi Linux - Newbie 3 06-20-2017 03:50 AM
[SOLVED] Importing data in OpenLDAP from remote Active Directory shahzad.fatehali Linux - General 1 03-10-2010 10:18 AM
Importing data in mysql? Frank Soranno Programming 3 08-20-2007 07:35 PM
Importing data from /dev/ttyUSB0 RVDowning Mandriva 1 06-29-2006 08:06 PM
mysqlimport problem alaios Linux - Software 3 03-17-2006 01:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration