简体   繁体   中英

Ingest multiple excel files to MySQL using query

I am trying to load data from excel files into a table in MySql. There are 400 excel files in.xlsx format.

I have successfully ingested one file into the table but the problem is that involves manually converting excel file into a csv file, saving it on a location and then running a query to load using LOAD LOCAL INFILE . How to do it for rest of the files.

How to load all the 400.xlsx files in a folder without converting them manually to.csv files and then running the ingestion query one by one on them.Is there a way in MySql to do that. For example, any FOR Loop that goes through all the files and ingest them in the table.

Try bulk converting your XLSXs into CSVs using in2csv as found in csvkit .

## single file
in2csv file.xlsx > file.csv

## multiple files
for file in *.xlsx; do in2csv $file > $file.csv; done

Then import data into MySQL using LOAD LOCAL INFILE...

From loading multiple CSVs, use for file in *.csv; do... for file in *.csv; do... or see How to Import Multiple csv files into a MySQL Database .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM