Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load data from text files in bulk using wildcards?

Status
Not open for further replies.

elsenorjose

Technical User
Oct 29, 2003
684
US
I have several text files I need to import into my DB and I'm looking for a shortcut using the LOAD DATA INFILE statement. The files are named using a number sequence which identifies the day for which the file exists:

wms.20070403.2007040300.vod.csv
wms.20070402.2007040200.vod.csv
wms.20070404.2007040400.vod.csv

Etc...

I've written a batch script which I call from the command line to import the data but it's a real pain to have to change the file names every time I get a new set of files. I have 30 files to import so I don't really look forward to 'find/replace'ing 30 lines of code. Is there a way to load the data using wildcards? Since all of these files will get imported into the same table, I would like to just write something like:

LOAD DATA LOCAL INFILE 'c:/data/*.vod.txt' INTO TABLE vod_table;

I've tried that and I get an error saying that file doesn't exist.

I haven't found anything on the MySQL site or Googling so I'm hoping I can get some help here.
 
Sorry...
Forgot environment info...
Using MySQL 5.0.27 on Windows XP
 
mysqlimport might get you some of the way there
then you would need a for..in loop in your batch file to repeat for each file in a directory

but.. dos batch files are fortunately a long and distant memory for me

on linux it is a relatively trivial problem using the find -exec utility .. I see there is a port of this utility to Windows never tried
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top