Solved

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

Posted on 2008-10-07
1
2,563 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 51

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

696 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