I have a folder on my local PC containing multiple CSV files. Files are named according to the date they were generated. Is there any way that we can get todays' date file (12/27/2021.csv) which is located in the CSV folder and import it into a google sheet?. There is this python resource which somewhat lets you do that but it is not what is needed.
I have used this google apps script code for importing CSV file from Google Drive to Google sheet:
function loadCSVFilesIntoSheets() {
var ss=SpreadsheetApp.openById('SpreadsheetId')
var folder=DriveApp.getFolderById('folderId');
var files=folder.getFilesByType(MimeType.CSV);
while(files.hasNext()) {
var file=files.next();
var vA=Utilities.parseCsv(file.getBlob().getDataAsString());
var ts=Utilities.formatDate(new Date(),Session.getScriptTimeZone(),"MM/dd/yy HH:mm:ss")
var sh=ss.insertSheet(file.getName()+'-'+ts);
sh.getRange(1,1,vA.length,vA[0].length).setValues(vA);
}
}
I have tried to use this Google sheet formula by providing a CSV file path but it gives an error because this path is not publicly accessible.
IMPORTDATA("file:///C:/Users/myUserName/myFolder/12/27/2021.csv")
Can we upload a CSV file that is currently in the PC folder to Google sheet using google apps script?