W
W
WebAnalytics12018-06-20 17:43:15
Google Apps Script
WebAnalytics1, 2018-06-20 17:43:15

How to import txt file with given delimiter options to google spreadsheet using script?

You need to import a txt file that looks like this 5b2a673c09e9f245097742.png
in google spreadsheets to get it like this
5b2a676fc768c590250351.png
There is a script that only imports but does not set the settings

function importCSVFromGoogleDrive() {
   var file = DriveApp.getFilesByName("programs-list.csv").next();
  var csvData = Utilities.parseCsv(file.getBlob().getDataAsString());
  var sheet = SpreadsheetApp.openById('ID').getSheetByName('Import');
  sheet.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);  
}

How to add import settings
Separator Type: Automatic
Convert Text to Numbers and Dates: No

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-06-20
@dimonchik2013

instead
of https://developers.google.com/apps-script/referenc...
write
https://developers.google.com/apps-script/referenc...
with parameters
about "automatically" forget, although Python has such libs that help determine the dialect

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question