-1

Hope you can help. Im looking to create a script to upload csv into a google sheet from a folder in the drive? is there a way to auto upload this once i have added to the folder?

thanks in advance

1 Answers1

0

You can use Google Apps Script to create a google sheet version of your csv file in your Google Drive. You can use the script below:

function myFunction() {
  var file = DriveApp.getFilesByName(your-filename-here).next();
  var csvData = Utilities.parseCsv(file.getBlob().getDataAsString());
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.getRange(1,1,csvData.length, csvData[0].length).setValues(csvData)
}
Jason E.
  • 1,201
  • 1
  • 3
  • 10
  • If I was to add a file to folder of any name who do I get it to upload? – Phil Benningwood Mar 03 '21 at 22:43
  • You can refer to this SO post for that one -> https://stackoverflow.com/questions/63374794/upload-file-to-my-google-drive-with-google-apps-script-no-form-in-google This includes the step by step process to do an upload to google drive via Apps script. – Jason E. Mar 03 '21 at 23:31
  • @PhilBenningwood if this answer helped you with your concern, please do upvote/accept it so that others will know the solution if they encounter the same problem. https://meta.stackexchange.com/help/someone-answers – Jason E. Mar 09 '21 at 20:48