Utilities.parseCsv() 'Could not parse text' (Google Apps Script) -


i'm confused because working earlier , don't know why broken now. i've got csv files i'm trying parse. i'm accessing them using following code:

var file = driveapp.getfilebyid(fileid); var csv = file.getblob().getdataasstring(); var data = utilities.parsecsv(csv); 

it crashes on 3rd line. when debugging, see looks normal... file object, csv string , based on preview think format looks correct csv ('header1,header2,header3 data1,data2,data3 data4,data5,data6...' etc). then, however, data undefined. causing error? i'm not finding online , debugging didn't provide me insight.

are there particular symbols in csv break function perhaps? there ' , " symbols in csv data... don't know why should matter.

update: file in question has 16000 lines. i'm going through in segments trying narrow down problem. isn't quotes; ran test parser follows , worked expected:

function myfunction() {   var = 'test""123,456\n';   var b = "abc' 'def,ghi\n";   var h = 'x,y\n';   var str = h+a+b;   var csv = utilities.parsecsv(str);   logger.log(str);   logger.log(csv); } 

the log file looked (expected):

x,y test""123,456 abc' 'def,ghi  [[x, y], [test""123, 456], [abc' 'def, ghi]] 

if have more ideas test might causing this, can test them.

i tried testing function slight modified , looks works okay. here's 1 used. if can share data file us, i'd glad take @ problem.

function prrrrse()  {   var br = '<br />';   var = 'test""123,456\n';   var b = "abc' 'def,ghi\n";   var h = 'x,y\n';   var str = h+a+b;   var delimiter = ',';   var csv = utilities.parsecsv(str,delimiter);   var s = 'str=' + str + br + 'delimiter=' + delimiter + br;   for(var = 0;i<csv.length;i++)   {     s+='csv[' + + ']=';     for(var j=0;j<csv[i].length;j++)     {       if(j>0)s+=' , ';       s+=csv[i][j];     }     s+= br;   }   dispstatus('parsing',s, 800, 600);  }   function dispstatus(title,html,width,height,modal) {   var title = typeof(title) !== 'undefined' ? title : 'no title provided';   var width = typeof(width) !== 'undefined' ? width : 400;   var height = typeof(height) !== 'undefined' ? height : 300;   var html = typeof(html) !== 'undefined' ? html : '<p>no html provided.</p>';   var modal = typeof(modal) !== 'undefined' ? modal : false;   var htmloutput = htmlservice      .createhtmloutput(html)      .setwidth(width)      .setheight(height);  if(!modal)  {    spreadsheetapp.getui().showmodelessdialog(htmloutput, title);  }  else  {    spreadsheetapp.getui().showmodaldialog(htmloutput, title);  } }  

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -