searching within a parsed csv file

ok here is what I want to do.
I want to be able to parse a csv file but I only want to keep lines that start with a certain character or set of characters

this is the code Im using:

$line = 0;
$maxCols = 0;

while (($line < $previewLimit) && ($data = fgetcsv($myFile, 2048, $delimiter))) {
$numOfCols = count($data);
if ($numOfCols > $maxCols) $maxCols = $numOfCols;

$csv_block .= "
";
I basically want to ignore any line with a 1 as the first character. how would I go about doing this? I know its probably a newb question but Im only a beginner hehe :) thank you

Comments

  • http://php.net/strstr

    with this function you can see if X is found in string Y. if true then the X is found. so a:

    if (strstr($y,$x)) {
    // X found
    } else {
    // Y found
    }

    : ok here is what I want to do.
    : I want to be able to parse a csv file but I only want to keep lines that start with a certain character or set of characters
    :
    : this is the code Im using:
    :
    : $line = 0;
    : $maxCols = 0;
    :
    : while (($line < $previewLimit) && ($data = fgetcsv($myFile, 2048, $delimiter))) {
    : $numOfCols = count($data);
    : if ($numOfCols > $maxCols) $maxCols = $numOfCols;
    :
    : $csv_block .= "
    ";
    : I basically want to ignore any line with a 1 as the first character. how would I go about doing this? I know its probably a newb question but Im only a beginner hehe :) thank you
    :

    [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    NEW url--> http://mark.space.servehttp.com

  • : http://php.net/strstr
    :
    : with this function you can see if X is found in string Y. if true then the X is found. so a:
    :
    : if (strstr($y,$x)) {
    : // X found
    : } else {
    : // Y found
    : }
    :
    I think strpos would be better.
    http://php.net/strpos

    That returns the position of one string in another, so you can see if it's at the start of the line.

    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.");

  • : : http://php.net/strstr
    : :
    : : with this function you can see if X is found in string Y. if true then the X is found. so a:
    : :
    : : if (strstr($y,$x)) {
    : : // X found
    : : } else {
    : : // Y found
    : : }
    : :
    : I think strpos would be better.
    : http://php.net/strpos
    :
    : That returns the position of one string in another, so you can see if it's at the start of the line.
    :
    : 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.");
    :
    :
    thanks guys I appreciate it =P that gives me an idea of how to do it.
Sign In or Register to comment.

Howdy, Stranger!

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

Categories