I'm looking for a way to convert a brut file into .txt then into spreadsheet using Google Apps Script.
I've already seen a way to convert xls into Google SpreadSheet with this script (using Drive API V2) :
function convert_XLS_To_SpreadSheet(){
var folder = DriveApp.getFoldersByName('RootFolder').next().getFoldersByName('depository').next();
var txtFile = folder.getFilesByName('file.xls').next();
Logger.log('Text File : ' + txtFile);
var resource = {
title : txtFile.getName(),
mimeType : MimeType.GOOGLE_SHEETS,
parents: [{id : folder.getId()}],
}
Drive.Files.insert(resource, txtFile.getBlob(),{
convert: true
});
txtFile.setTrashed(true);
}
I tried to do the same by replacing the file I wanted into txt format but it's giving me a Google Doc even if I provide the correct MimeType.