Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

parsing a .csv file

shadowsilshadowsil Posts: 3Member
ok heres my dilemma...I need to parse a .csv file into usable data...first I have to split the data by commas...the problem is I dont know how to split the data correctly as not all of the data is only seprated by one comma. can someone help me out?
each line looks like this

bla bla bla,blablabla,bla bla bla,,,bla bla bla,,blablabla,blablabla,.

Comments

  • JonathanJonathan Posts: 2,914Member
    : ok heres my dilemma...I need to parse a .csv file into usable
    : data...first I have to split the data by commas...the problem is I
    : dont know how to split the data correctly as not all of the data is
    : only seprated by one comma. can someone help me out?
    : each line looks like this
    :
    : bla bla bla,blablabla,bla bla bla,,,bla bla bla,,blablabla,blablabla,.
    :
    So you are saying you want to split on one or more commas, and ignore the fact that there are empty fields between them? If so, use something like:-

    data_array = preg_split(",+", csv_line);

    For more info, see:-
    http://uk.php.net/manual/en/function.preg-split.php

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.