In google App Script, while trying to import via link a csv into a spreadsheet, I'd like to modify a string to correctly run Utilities.parseCsv, but the replace doesn't seem to work. Where am I wrong? I specify that in the csv all the strings are in double quotes like:
name, color, age
"Mary","red","33"
"Paul","blue","34"
"John","black","35"
the csv I need to import is this:
but if I try to import it throws me Exception: Could not parse text.
in the csv there are lines like this:
"istsc_tpis008004","POLO STATALE DI ISTRUZIONE SECONDARIA SUPERIORE "P.MATTARELLA"","Castellammare del Golfo","081005","TP","081","Sicilia","19",7301.0,"1.4.1 Esperienza del Cittadino - Scuole - Aprile 2022","2022-06-20T10:22:19.000+0000","2022-08-19","J21F22001670006",2.0,33.0,"A"
with double quotes next to it "" which I think creates the problem.
that's why i want to edit the csv between var csvContent = UrlFetchApp.fetch(csvUrl).getContentText(); and var csvData = Utilities.parseCsv(csvContent,',');
A thousand thanks
function uploadCsv(csvUrl, sheetName, row, column) {
var csvContent = UrlFetchApp.fetch(csvUrl).getContentText();
csvContent.replace(/stringToModify/g, "modifiedString");
var csvData = Utilities.parseCsv(csvContent, ',');
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
sheet.getRange(row, column, csvData.length, csvData[0].length).setValues(csvData);
}
setValueswill become in the cells a string,string,number Mary,red,33console.log(csvContent);?