This is possible in NetSuite SuiteScript with iterator approach
Introduction Handling large files in NetSuite can be challenging due to the platform’s file size limitations. This guide provides strategies and code examples to efficiently read and process files larger than 10 MB using an iterator approach.
Understanding NetSuite’s File Cabinet The NetSuite File Cabinet is a convenient way to store files. However, due to script execution and memory limitations, files larger than 10 MB require special handling to avoid performance issues or script timeouts.
- You can read files easily with files.iterator
- You can simply append the lines
Code Snippet:
let sampleFile = file.load({
id: 123 //replace with your file internal id
});
let iterator = sampleFile.lines.iterator();
let result = iterator.next().value.split(',');
var dynamicObject = {};
for (var i = 0; i < result.length; i++) {
dynamicObject[result[i]] = '';
}
log.debug('objone', dynamicObject);
var keys = Object.keys(dynamicObject);
var fileObj = new Array();
iterator.each(function(line) {
var lineValues = replaceCommas(line.value).split(',');
for (var i = 0; i < keys.length; i++) {
dynamicObject[keys[i]] = lineValues[i];
}
fileObj.push(dynamicObject);
return true; });
log.debug('fileObj', fileObj);
0 Comments