function wise() {
SpreadsheetApp.getActiveSpreadsheet().setSpreadsheetLocale("de")
const ss = SpreadsheetApp.getActiveSheet()
let lr = ss.getLastRow()
ss.getRange(1,1,lr,1).splitTextToColumns(SpreadsheetApp.TextToColumnsDelimiter.COMMA)

// Set Top Array, lc
let lc = ss.getLastColumn()
ss.insertColumnsAfter(lc,2)
let topRange = ss.getRange(1,1,1,lc)
let topArrayBD = topRange.getValues()
let topArray = topArrayBD.flat()


const iMerchant = topArray.indexOf("Merchant")+1
ss.insertColumnAfter(iMerchant)
const iAmount = topArray.indexOf("Amount")+1
const iDate = topArray.indexOf("Date")+1
const iPayerName = topArray.indexOf("Payer Name")+1
const iPayeeAccount = topArray.indexOf("Payee Account Number")+1
ss.getRange(2,iAmount,lr,1).createTextFinder(".").replaceAllWith(",")
ss.getRange(2,iDate,lr,1).setNumberFormat("dd.MM.yyyy")

ss.deleteColumn(iPayeeAccount)


lc=ss.getLastColumn()
let threeRowsDB = ss.getRange(2,iPayerName,lr-1,3).getValues()
let threeRows = threeRowsDB.flat()

    let empfangerArray = []
    for (let i = 0; i<threeRowsDB.length; i++) {
      threeRowsDB[i].join("")!=="" ? empfangerArray.push(threeRowsDB[i].join("")) : empfangerArray[i] = "Wise" 
    } 


let empfangerArrayDB = empfangerArray.map(x => x = [x])

ss.getRange(1,iMerchant,1,1).setValue("Empfänger/Zahlungspflichtiger")
ss.getRange(2,iMerchant,lr-1,1).setValues(empfangerArrayDB)
topRange = ss.getRange(1,1,1,lc)
topArrayBD = topRange.getValues()
topArray = topArrayBD.flat()
ss.getRange(1,topArray.indexOf("TransferWise ID")+1,1,1).setValue("Buchungstext")
ss.getRange(1,topArray.indexOf("Date")+1,1,1).setValue("Buchungsdatum")
ss.getRange(1,topArray.indexOf("Amount")+1,1,1).setValue("Betrag")
ss.getRange(1,topArray.indexOf("Currency")+1,1,1).setValue("Währung")
ss.getRange(1,topArray.indexOf("Description")+1,1,1).setValue("Verwendungszweck")
ss.getRange(1,topArray.indexOf("Payment Reference")+1,1,1).setValue("Zahlungsreferenz")

// Mark columns to be filtered
    topRange = ss.getRange(1,1,1,lc+1)
    topArrayBD = topRange.getValues()
    topArray = topArrayBD.flat()
    const stayArray = ["Buchungsdatum","Buchungstext","Zahlungsreferenz","Betrag","Empfänger/Zahlungspflichtiger","Währung","Verwendungszweck"]

    //Filter irrelevant Columns 
    const indices = [];
    topArray.forEach((element, index) => {
      if(!stayArray.includes(element)){
         indices.push(index);
      };
   });

    //Delete irrelevant columns
    for (let i =indices.length-1; i >=0; i-- ) {
        ss.deleteColumn(indices[i]+1)
      }
  ss.getRange("C2:C"+lr).setNumberFormat("0.00").createTextFinder(",").replaceAllWith(".")
  ss.getRange("C2:C"+lr).setHorizontalAlignment("right")



}
