cybeeer
cybeeer

Reputation: 3

Is there anyway to import a csv file that contains multiple worksheets using LOAD DATA INFILE

The load data infile only imports the first sheet.

"LOAD DATA INFILE 'C:\Users\\user\\Desktop\\example.csv'
INTO TABLE exampletable FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES (Id, Name)";

Is it possible to upload the 2nd sheet simultaneously with the first sheet?

Upvotes: 0

Views: 616

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521229

When you export a worksheet in an Excel workbook to CSV, you usually do so one sheet at a time. So, to do what you want you might have to open the first CSV file and append the second one at the end. This assumes that both sheets would have the same number and types of columns. You also might have to remove the header row from the second CSV file before combining it.

It should be possible to write a VBA script to iterate all sheets and generate a single CSV output. But that would be a bit of work, and perhaps not worth it for you to do.

Upvotes: 0

Related Questions