DEV Community

Cover image for Merge multiple Excel into a database table
ryjfgjl
ryjfgjl

Posted on • Edited on

Merge multiple Excel into a database table

This article will introduce how to batch merge the data of multiple excel files into a database table.

Prepare data

As shown in the figure, we need to merge the data of 4 excel files into one.

DiLu Converter

The headers of the files are the same, but the data is different. Even if the headers are different, we can choose to ignore or add different columns

Start merging

Open the DiLu Converter tool, select the file to be merged, select Specified for the target table, and enter the table name or select a table that already exists in the database

DiLu Converter

View the results

You can see that 4 excel files were merged in 2 seconds, with a total of 40,000 rows

DiLu Converter

Continue to optimize

Although the data here is merged, if you want to distinguish which file each row of data comes from, how to do it?

Select Override in the import mode, then switch to the database options interface, and fill in the field to save the Excel name

DiLu Converter

After re-importing the data, you can see that a new source field has been added to the table

DiLu Converter

Here, by default, the name of the Excel workbook and worksheet is added to the end of each row of data. If you only want to save some characters in the file name, such as the date here, how to deal with it?

Select Rebuild in the import mode, save the Excel table name (regular extraction) to the column, select the Date (YYYYMMDD), and fill in the data_date in the field name. If you want to extract other characters, you can also write a regular expression to extract it yourself

DiLu Converter

View the data again

DiLu Converter

Top comments (0)