Read and Log Segments of a File Using a Set of Characters as Separators
The following sample reads and logs segments from a file using a set of characters as separators.
Note:
This script sample uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects.
/**
* @NApiVersion 2.x
* @NScriptType bankStatementParserPlugin
*/
define(['N/file', 'N/log'], function(file, log) {
return {
parseBankStatement: function(context) {
var statementFile = context.input.file;
var statementSegmentIterator = statementFile.getSegments({separator: '\\|_|/'}).iterator();
statementSegmentIterator.each(function (segment) {
log.debug({
title: 'STATEMENT TEXT',
details: segment.value
});
return true;
});
}
}
});
Related Topics
- N/file Module Script Samples
- Create and Save a File to the File Cabinet
- Create a File, Set Property Values, and Save It to the File Cabinet
- Create and Save a CSV File then Reload the File and Parse Its Contents
- Read and Log File Contents Using Commas and New Lines as Separators
- Copy a File Using Conflict Resolution
- SuiteScript 2.x Modules
- SuiteScript 2.x