Here's what I would do.

In your loop:

for(var i:int = 0; i<rows.length; i++)
{
//you would include an if statement here to not include lines that begin
with //
var columns:Array = rows[i].split(",");//split each row into columns
temp.push({id:columns[0],name:columns[1],position:columns[2]});
}

I would add this:

for(var i:int = 0; i<rows.length; i++)
{
//you would include an if statement here to not include lines that begin
with //
var row:String = rows[i];
if (row.substr(0,2) == "//") {
continue;
}

var columns:Array = rows[i].split(",");//split each row into columns
temp.push({id:columns[0],name:columns[1],position:columns[2]});
}


Hope that helps.



--- In [email protected], "~[TM3]~[Dev]At0ng[/Dev]~[/TM3]~"
<atong...@...> wrote:
>
> I recently have this code from gotoandlearnforums to parse datas
> separated with commas from a text file but the problem is I dunno (I
> really had no idea how) how to exclude rows that begins with a double
> slashes (//), hope someone can help me with this. Parsing datas is ok
> but excluding rows is not           private function
init(e:Event):void
> {             //load the data             var loader:URLLoader = new
> URLLoader(new URLRequest("stuff.txt"));
> loader.addEventListener(Event.COMPLETE, parseData);          }
> private function parseData(e:Event):void          {
> var txt:String = e.target.data;             var rows:Array =
> txt.split("\r\n");//split the string into rows
> var temp:Array = new Array();                          for(var i:int =
> 0; i<rows.length; i++)             {                //you would
include
> an if statement here to not include lines that begin with //
> var columns:Array = rows[i].split(",");//split each row into columns
> temp.push({id:columns[0],name:columns[1],position:columns[2]});
> }             ac = new ArrayCollection(temp)
>

Reply via email to