Skip to content Skip to sidebar Skip to footer

Google Apps Script Runtime Chrome V8 Causes Error In And Utilities.parsecsv(csv, Delimiter) When Delimiter Is ' ' (space)

In Google App script, I need to split a string using space as delimiter. I have used Utilities.parseCsv. Worked fine. Then, I switched my script code to the new V8 runtime and enco

Solution 1:

  • You want to use Utilities.parseCsv(csv, delimiter) under V8.

If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.

I think that this might be one of bugs for V8. Although I think that this might be resolved in the future update. As the current workaround, from the error message of Exception: Cannot convert '' to char., how about the following modification?

From:

vardata = Utilities.parseCsv(csvString, ' ');

To:

vardata = Utilities.parseCsv(csvString, ' '.charCodeAt(0));

or

vardata = Utilities.parseCsv(csvString, Utilities.newBlob(' ').getBytes());

Result:

[["Prefix","Middle","Suffix"]]

Note:

  • In above modified script, it can be used with and without enabling V8.

References:

If I misunderstood your question and this was not the direction you want, I apologize.

Post a Comment for "Google Apps Script Runtime Chrome V8 Causes Error In And Utilities.parsecsv(csv, Delimiter) When Delimiter Is ' ' (space)"