define(["N/file"], function (f) {
/**
* Custom module for executing N/file cookbook examples
*
* @NApiVersion 2.0
* @NModuleScope SameAccount
*/
var exports = {};
function readFile(response) {
var weatherFile = f.load({id: "SuiteScripts/weather.csv"});
var weatherData = [];
weatherFile.lines.iterator().each(function (line) {
var w = line.value.split(",");
weatherData.push({date: w[0], low: w[1], high: w[2]});
return true;
});
response.write({output: JSON.stringify(weatherData)});
}
exports.readFile = readFile;
return exports;
});