Search code examples
javascriptcsvgoogle-apps-scriptgoogle-sheetsdouble-quotes

Extra double quotes in csv coming in Google Sheets Apps Script Web App


In my google sheet I have some data in it. Later I published my sheet as .csv format.

Pls find my sheet here, below are the Cell Values


C1 = tdsyltt = 'ఈరోజు ( బుధవారం )  క్విజ్ సిలబస్' ;

C2 = tdsyl = 'హబక్కూకు 1 & యాకోబు 2, 3' ;

C4 = document.getElementById("tdsyltt).innerHTML = tdsyltt ;

C5 = document.getElementById("tdsyl").innerHTML = tdsyl ;

And using my published URL I have developed a web app

code.gs

const doGet = _ => ContentService.createTextOutput(UrlFetchApp.fetch("https://docs.google.com/spreadsheets/d/e/2PACX-1vReY-tDEwKYjTiSjsfAN42qjFUwMv_OD3_64bFdGrgL-2p3otc13elLcCq3pkb5xqhTA-bW3QXobpqh/pub?gid=1861615717&single=true&range=c1:c5&output=csv").getContentText()).setMimeType(ContentService.MimeType.JAVASCRIPT);

In the web app output 1st line is ok,

but for 2nd, 3rd and 4th line there are Extra 2 Apostrophes coming at the starting and ending of the lines.

Here is My Web App

enter image description here

How to fix this ..?


Solution

  • Try a way to solve this by changing the spreadsheet Publishing Format from csv to tsv then it will work.

    Code.gs

    const doGet = _ => ContentService.createTextOutput(UrlFetchApp.fetch("https://docs.google.com/spreadsheets/d/e/2PACX-1vReY-tDEwKYjTiSjsfAN42qjFUwMv_OD3_64bFdGrgL-2p3otc13elLcCq3pkb5xqhTA-bW3QXobpqh/pub?gid=1861615717&single=true&range=c1:c5&output=tsv").getContentText()).setMimeType(ContentService.MimeType.JAVASCRIPT);