Modules

filter

 

Objects/Functions

module (N/file)

SuiteScript 2.0

File.lines.iterator()

{File}.lines.iterator(){lineContext: {iterator*}})

N/file Module
File.lines.iterator()
Method Description: Method used to pass the next line as an argument to a developer-defined function. You can call this method multiple times to loop over the file contents as a stream. Return false to stop the loop. Return true to continue the loop. By default, false is returned when the end of the file is reached. This method can be used on text or .csv files. Content held in memory is limited to 10MB. Therefore, each line must be less than 10MB.
Returns: boolean
Supported Script Types: Server-side scripts For more information, see SuiteScript 2.0 Script Types.
Governance: None
Module: N/file Module
Since: 2017.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=File.lines.iterator()

Example:

// Code Example 1
//Add additional code
//...
var iterator = invoiceFile.lines.iterator();

//Skip the first line (CSV header)
iterator.each(function () {return false;});
iterator.each(function (line)
{
// This function updates the total by
// adding the amount on each line to it
var lineValues = line.value.split(',');
var lineAmount = parseFloat(lineValues[1]);
if (!lineAmount)
throw error.create({
name: 'INVALID_INVOICE_FILE',
message: 'Invoice file contained non-numeric value for total: ' + lineValues[1]
});

total += lineAmount;
return true;
});
//...
//Add additional code

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4769955095.html