let veebikaust="https://minitorn.tlu.ee/~jaagup/oma/too/23/08/keel/mustrisagedused/osakaalud_jarjestatud/"; let failinimi="K1_arvamuslood_parem.txt"; let sisendfail=veebikaust+failinimi; function looTabel() { let raamat=SpreadsheetApp.create("mustrisagedused_"+failinimi.substring(0, failinimi.length-4)); let leht=raamat.getSheets()[0]; let fail = DriveApp.getFileById(raamat.getId()); let kaust = DriveApp.getFolderById("1gBzxdpLM2wn64ynPn2jqpQmvQv2XrFHV"); fail.moveTo(kaust); let tekst=UrlFetchApp.fetch(sisendfail).getContentText(); andmedSaabusid(tekst, leht); //console.log(tekst); } function andmedSaabusid(tekst, leht){ // console.log(tekst); let reanr=2; let veerunr=1; for(let rida of tekst.split("\n")){ if(rida.startsWith("Kokku")){ leht.getRange(1, 1).setValue(rida); leht.getRange(2, 1).setValue("MUSTER\nsagedus/osakaal üldkogumis(%)") } else if(!rida.startsWith(" ")){ reanr++; veerunr=2; m=rida.split(","); if(m.length==3){ leht.getRange(reanr, 1).setValue(m[0]+"\n"+m[1]+"/"+m[2].substring(0, m[2].length-1)); } } else { m=rida.split(","); leht.getRange(reanr, veerunr).setValue(m[0]+"-"+m[1]+"\n"+m[2].substring(0, m[2].length-1)); veerunr++; } } }