Plucka
asked on
Looping Over a List
Hi,
I have a comma delimited list, how do I loop over it. It's being passed into a function
ie
x = functionName('one,two,thre e,four,fiv e');
I see there is a List data type and also thought of doing this by converting it to an array.
I have a comma delimited list, how do I loop over it. It's being passed into a function
ie
x = functionName('one,two,thre
I see there is a List data type and also thought of doing this by converting it to an array.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There are classes to read the whole csv file.
I copy pasted from a class i have. The above should work, but this is just for a tip.
var csvfile:LoadVars;
var linesep:String;
var lines:Array;
var linelen:Number;
var line:String;
var record:Array;
var recsep:String;
var recval:Number;
//
csvfile = new LoadVars();
csvfile.load("customers.cs v");
//
csvfile.onData = function(csv:String) {
linesep = chr(13)+chr(10);
lines = csv.split(linesep);
linelen = lines.length;
line = '';
//
recsep = chr(44);
//
record = new Array();
for (var i:Number = 0; i<linelen; i++) {
//
line = lines[i];
record[i] = line.split(chr(44));
//
recval = record[i].length-1;
// Trace first value from each record
trace(record[i][0]);
}
};
var csvfile:LoadVars;
var linesep:String;
var lines:Array;
var linelen:Number;
var line:String;
var record:Array;
var recsep:String;
var recval:Number;
//
csvfile = new LoadVars();
csvfile.load("customers.cs
//
csvfile.onData = function(csv:String) {
linesep = chr(13)+chr(10);
lines = csv.split(linesep);
linelen = lines.length;
line = '';
//
recsep = chr(44);
//
record = new Array();
for (var i:Number = 0; i<linelen; i++) {
//
line = lines[i];
record[i] = line.split(chr(44));
//
recval = record[i].length-1;
// Trace first value from each record
trace(record[i][0]);
}
};