#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2010
    Posts
    84
    Rep Power
    5

    Can someone tell me if there is already a funciton for this?


    Hey there people,

    I have a file in this format:-

    FIRST_VALUE, This is a value
    SECOND_VALUE, This is another value
    THIRD_VALUE, This is also a value

    I use a function to read this data into an array which ends up like this:-

    first_array(0) = "FIRST_VALUE, This is a value"
    first_array(1) = "SECOND_VALUE, This is another value"

    How the heck do I take that array an split it down the middle so that I have something like this:-

    first_array(0) = "FIRST_VALUE"
    second_array(0) = "This is a value"

    etc, etc.

    Any ideas?

    Cheers
    MRb
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0
    To me that sounds like a problem for the RegEx-Namespace (regular Expressions). Although I am currently not too familiar with that this sounds as if you just need to search for the x-th occurence of a sequence of letters, starting with a capital one and terminated by a "," and put each into the (x-1)-th position inside your array.
    Maybe you can also work with string.IndexAt(string s) to search for the "," and "\n" symbols and cut of, what you don't need with string.trim().
    At least the first option will work fine, although it might be a little bit more complicated than using the options of the string-class.

    Best regards!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2010
    Posts
    84
    Rep Power
    5
    Thank you for your reply, I'll report back on how I solved this one when I do.

    Cheers,
    MRb
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    144
    Rep Power
    17
    Read You file usinf .ReadLine() then on the returning string call string.split(",") you will get an array with two elements with each of the elements.

IMN logo majestic logo threadwatch logo seochat tools logo