Thanks to all who helped me, I really appreciate it.
 



----- Forwarded Message ----
From: Cory <[email protected]>
To: [email protected]
Sent: Sunday, January 24, 2010 4:13:57
Subject: [flexcoders] Re: [HELP] Little help with parsing datas

  
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 flexcod...@yahoogro ups.com, "~[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.addEventList ener(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)
>

 


      Open emails faster. Yahoo! recommends that you upgrade your browser to 
the new Internet Explorer 8 optimized for Yahoo! Get it here! 
http://downloads.yahoo.com/sg/internetexplorer/

Reply via email to