With a help from a friend,I have a code that uploads a txt file and here it is.
document.getElementById('file').onchange = function(){
var file = this.files[0];
var reader = new FileReader();
reader.onload = function(progressEvent){
// Entire file
console.log(this.result);
// By lines
var lines = this.result.split('\n');
for(var line = 0; line < lines.length; line++){
// By tabs
var tabs = lines[line].split('\\t');
for(var tab = 0; tab < tabs.length; tab++){
console.log(tabs[tab]);
}
}
};
reader.readAsText(file);
};
<input type="file" name="file" id="file">
and this is my code.gs
function doGet(e){
var html = HtmlService.createHtmlOutputFromFile("index");
return html;
}
function work(res){
var ss = SpreadsheetApp.getActiveSheet();
ss.getRange(1,1,res.length,res[0].length).setValues(res);
}
The output of this code is :
Upload a Tab Seperated File
Convert that file into array
Insert that array in Google Sheet
Actually the code is working but there is a problem. the google sheet has an initial of 1000 rows and I encountered a scenario where I will upload a file that contains million rows. How can I adjust the no. of rows in sheet based on the number of arrays.