MySQL Forums
Forum List  »  InnoDB

Re: Import Multiple CSV Files in Windows
Posted by: Ian Coan
Date: September 04, 2015 01:08PM

The following is the code I used when trying the mysql.exe command. This also did not work. However this is the code that was generated from HEIDI SQL software when I tried to import just one CSV file at a time. That worked flawlessly, one at a time. I want to make it do it multiple times for all CSV files I have from a batch file. I obscured filed names, database name and table name. Any suggestion as to an exact code example from start to finish on how to make this work? What you see here is an example I found while searching. I don't even know what it does.


FOR %%f IN ("*.csv") DO (
set old=%%~dpnxf
set new=!old:\=\\!
mysql -e -u root -pPASSWORD "LOAD DATA LOW_PRIORITY LOCAL INFILE '"!new!"' INTO TABLE `DB NAME`.`TABLE NAME` CHARACTER SET utf8 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n' IGNORE 3 LINES (`FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`, `FILED NAME`)"
echo %%~nxf DONE
)

Options: ReplyQuote


Subject
Views
Written By
Posted
3842
August 31, 2015 12:09PM
1309
August 31, 2015 12:41PM
1498
September 02, 2015 08:19PM
1217
September 04, 2015 11:22AM
Re: Import Multiple CSV Files in Windows
2451
September 04, 2015 01:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.