function importData() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName("data");
const folder = DriveApp.getFolderById('xxxxx');
sheet.getRange(2, 1, sheet.getLastRow(), sheet.getLastColumn()).clear()
const files = folder.getFiles();
let sortFiles = []
while (files.hasNext()) {
sortFiles.push(files.next());
}
sortFiles.sort(function (a, b) { if (a.getName() > b.getName()) { return 1 } else { return -1 } })
let allSetData = []
for (const iterator of sortFiles) {
const file = iterator;
const data = file.getBlob().getDataAsString("UTF-8");
const csv = Utilities.parseCsv(data);
const setData = csv
setData.shift()
setData.reverse()
const lastRow = sheet.getLastRow();
Logger.log(setData)
allSetData = [...allSetData, ...setData]
if (setData.length > 0) sheet.getRange(lastRow + 1, 1, setData.length, setData[0].length).setValues(setData);