Convert CSV file into the JSON format

Using the Papa Parse javascript library we can easily convert CSV files into Netsuite.

How to use papa parse in Netsuite

  1. goto the papa parse website (https://www.papaparse.com/).
  2. download the minified js file by clicking the downlad button.

4. Extract the downloaded zip file and add the “papaparse.min.js” file in suitescript folder of the NetSuite file cabinet.

5. create a custom module using the relative path of file cabinet directory

sample: define([‘N/search’, ‘N/record’, ‘N/file’, ‘N/email’, ‘N/runtime’, ‘/SuiteScripts/Jobin and Jismi IT Services/BTN-1699 Invoice Creation Using CSV/papaparse.min.js‘], (search, record, file, email, runtime, papa) => {});

Use this papa module to convert the CSV file into JSON.

var uploadFile = file.load({ id: uploadFileId });
            var csvContent = uploadFile.getContents();
            var newValue = papa.parse(csvContent, {
                header: true,
                skipEmptyLines: tru
});

Leave a comment

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