3 Replies Latest reply on Sep 24, 2009 12:06 PM by Whitetimer

    cvs problem ?

    Whitetimer Level 1

      Hi All

       

      Ok what i'd like some help on is this ..

       

      I have been presented with a csv file that looks like this :-

       


      wp_bitfields=(0)
      WP_PTRS=(140,142,-1,0)
      wp_pos=(684.4507,118.6036,-329.4196)
      wp_perp=(-0.7525,-0.0079,-0.6585)
      wp_width=(5.100,8.500,10.100,13.500)
      wp_dwidth=(10.640,14.966,0.000,0.000)
      wp_path=(0.0000,0.0000)
      wp_galpha=(0.0000)
      wp_score=(0,723.779)
      wp_groove_lat=(0.000000)
      wp_event=(1.000,0,0)
      wp_branchID=(0)
      wp_bitfields=(0)
      WP_PTRS=(141,143,-1,0)
      wp_pos=(687.8313,118.5980,-333.2336)
      wp_perp=(-0.7448,-0.0031,-0.6673)
      wp_width=(5.675,7.950,9.927,12.950)
      wp_dwidth=(9.927,14.107,0.000,0.000)
      wp_path=(0.0000,0.0000)
      wp_galpha=(0.0000)
      wp_score=(0,728.876)
      wp_groove_lat=(0.000000)
      wp_event=(1.000,0,0)

       


      I know how to parse a normal csv file into an array etc, but what i'm stuck on is how i can parse just the data within the brackets only !!!

       

      Any suggestions ?

       

      Many thanks

       

      Whitetimer

        • 1. Re: cvs problem ?
          msakrejda Level 4

          Everybody stand back. I know regular expressions. ( http://xkcd.com/208/ )

           

          var lines:Array = [ ... ]; // array of lines in file--I'm not sure how exactly you're getting the data, but I assume you can get it to this point

          for (var line:String in lines) {

            var csvLine:String = line.replace(/.*\((.*)\)/, '$1');

            // do something with csvLine

          }

          • 2. Re: cvs problem ?
            Whitetimer Level 1

            Hi msakrejda ... Thanks for the help, though i'm more confused now.  I get the file as a long list as i posted, several 1000 rows of data like this

             

            wp_pos=(-201.4571,118.6937,548.7139)
            wp_perp=(-0.2652,0.0292,0.9638)
            wp_width=(9.950,3.625,14.950,8.625)
            wp_dwidth=(17.484,11.194,0.000,0.000)
            wp_path=(0.0000,0.0000)
            wp_galpha=(0.0000)
            wp_score=(1,2906.966)
            wp_groove_lat=(0.000000)
            wp_event=(1.000,0,0)
            wp_branchID=(0)
            wp_bitfields=(0)
            WP_PTRS=(564,566,-1,0)

             

            What i am trying to do is to read for instance, all the data between the brackets from say row 'wp_pos' only. And that what i'm stuck on.  I'm a newbie with actionscript and still learning, thats why i'm having trouble .... :~)

             

            Many Thanks

            • 3. Re: cvs problem ?
              msakrejda Level 4

              List? As in an ArrayCollection? If so, I think you'll have to loop over it and look for the matching item:

               

               

              for each (var line:String in myData) {

                var match:Array = line.match(/wp_pos=\((.*)\)/);

                if (match) {

                  var csvLine:String = match[1];

                }

              }