Using Suitescript, resolve splitting of single data into multiple columns in csv file when there are comma (,) and quotes (“) included in the data.

Consider the value inside variable data as “30″ PVC, 10-meter pipe”. There is a chance of splitting it into “30″ PVC” in one column and “10-meter pipe” in another column. This issue will still persist even after using JSON.stringify. To resolve this, refer the code below.

let data = "30" PVC, 10-meter pipe";
let dataForCsv = '"' + data.replace(/"/g,'""') + '"';

Leave a comment

Your email address will not be published. Required fields are marked *