I want to work with a csv file delimited by ;
. In some fields, we have commas, but it's ok.
An example line is as follows (notice there is a comma in one column):
01.02.2018;01.02.2018;"SEPA-Dauerauftrag an";Maier, Herbert;RINP Dauerauftrag Miete Kr?pelinstr. 61;DE45700100800225067803;PBNKDEFFXXX;;;;;;;;;-900,00;;EUR
The Google Apps Script code that I use is as follows;
function importCSVFromGoogleDrive() {
var ss = SpreadsheetApp.openById('<wb id>');
var outputSheet = ss.getSheetByName('import');
var fileIterator = DriveApp.getFilesByName("Kontoumsaetze_220_320895600_20180728_155842_DEV.csv");
var csv = fileIterator.next().getBlob().getDataAsString('ISO-8859-1');
Logger.log(csv);
var csvData = Utilities.parseCsv(csv, ";");
Logger.log("-------------");
Logger.log(csvData);
}
I just want to separate using ;
, but I can not achieve it. GAS keeps separating also the comma and this breaks my program.
- Why is it separating by
,
if I am telling ;
.
- How can I fix the issue?
Here are the logs (it separates using the comma, in Mayer, Herber
):
[18-07-29 18:42:22:922 CEST] 01.02.2018;01.02.2018;"SEPA-Dauerauftrag an";Maier, Herbert;RINP Dauerauftrag Miete Kr?pelinstr. 61;DE45700100800225067803;PBNKDEFFXXX;;;;;;;;;-900,00;;EUR
[18-07-29 18:42:22:923 CEST] -------------
[18-07-29 18:42:22:924 CEST] [[01.02.2018, 01.02.2018, SEPA-Dauerauftrag an, Maier, Herbert, RINP Dauerauftrag Miete Kr?pelinstr. 61, DE45700100800225067803, PBNKDEFFXXX, , , , , , , , , -900,00, , EUR]]
See Question&Answers more detail:
os