Solved

import multiple data files using mysql's LOAD DATA INFILE statement from the command line.

Posted on 2008-10-07
1
2,462 Views
Last Modified: 2012-05-05
I am trying to import not just one but numerous flatfile csv files using LOAD DATA INFILE statement from the mysql command line.  Using the code ive posted below i can insert a single .csv file but I need to be able to insert all .csv files that are in the same directory.  

Ive tried using *, %, and .*\  as wildcard operators but none of them have worked.


mysql --user=username --password=mypassword LOAD DATA LOCAL INFILE 'c:\\\files\\\\\\date20080808.txt.csv' INTO TABLE mytable FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' (field1, field2, field3)

Open in new window

0
Comment
Question by:cebrooks03
1 Comment
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 22665874
http://dev.mysql.com/doc/refman/5.1/en/load-data.html

The docs do not specifically state it, but I believe it is designed to read a *single* text file.  To import multiple files, you would execute multiple command lines - one for each file.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now