Reputation: 318
I have a very simple CSV file, with lots of different numerical values. How can I import this file in to netsuite and save the values in to an array, so that I can use said array in my scripts?
Upvotes: 1
Views: 2279
Reputation: 33
Do you prefer to use the CSV directly from your scripts? You could also import the CSV, loading it's values into a "Custom List" in Netsuite -- which can be accessed from scripts as well as forms, etc...
Upvotes: 0
Reputation: 11730
You can upload the file into the file cabinet for retrieval using nlapiLoadFile(id)
for parsing by scripts.
We use this strategy for processing:
var loadedInvoiceFile = nlapiLoadFile(invoiceFileId); //load the file
var loadedInvoiceString = loadedInvoiceFile.getValue(); //read its contents
var invoiceLines = loadedInvoiceString.split('\n'); //split on newlines
for (var i = 0; i < invoiceLines.length; i++) { //for each line do:
var cols = invoiceLines[i].split('\t'); //change delimeter here
...
}
Upvotes: 4
Reputation: 577
Check the Netsuite File API:
SuiteCloud (Customization, Scripting, and Web Services) : SuiteScript : SuiteScript API : SuiteScript Functions : File APIs
Using this API you can create a file in your Netsuite file cabinet. You can then use the file load API so you can read the contents of the file of the specific item in the file cabinet and create array from it via suitescript.
Upvotes: 1