on the bleeding edge, not sure I belong there...stream_get_line()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Crouch

    on the bleeding edge, not sure I belong there...stream_get_line()

    I have urgent need of the function stream_get_line :

    which as you can see is only P5 and above. So I went and got the PHP5
    source, hoping to find this function and copy it into my script.

    found php_streams.h
    don't really know what to do with it...I'm learning a little bit of C but
    not enough, I suspect.

    Is this a fool's hope? Is there an existing (4.3) function that can be
    tweaked to do the same job?

    If you're still with me, here's why I need it:

    I use .csv files in an import script, and one of the fields in these files
    has a lot of new line characters. In fact, the "field" is really an entire
    page of html. The .csv looks kinda like this:

    "spykids.jpg";" na.jpg";"noQval ue";"0.45";"S py Kids";"<big><b> This is a
    previously-viewed DVD in the original case. Both the DVD and case are in
    excellent condition and come with a life-time guarantee. </big></b><br><br>

    <b>The Original One!</B><br>
    (2002) Color - 88 Minutes
    <br><BR>

    ....and so on

    So the usual fgetcsv() doesn't work -- it interprets each new-line as a new
    record (even though it's enclosed within double quotes). My thought is that
    using stream_get_line with the double-quote defined as the ending would be
    the way to override this behavior.


  • Jon Kraft

    #2
    Re: on the bleeding edge, not sure I belong there...stream_ get_line()

    "Matthew Crouch" <matthew.crouch @spamlessverizo n.net> wrote:
    [color=blue]
    > "spykids.jpg";" na.jpg";"noQval ue";"0.45";"S py Kids";"<big><b> This is a
    > previously-viewed DVD in the original case. Both the DVD and case are
    > in excellent condition and come with a life-time guarantee.
    > </big></b><br><br>
    >
    > <b>The Original One!</B><br>
    > (2002) Color - 88 Minutes
    > <br><BR>
    >
    > ...and so on
    >
    > So the usual fgetcsv() doesn't work -- it interprets each new-line as
    > a new record (even though it's enclosed within double quotes).[/color]

    It works fine on my system (PHP 4.3.2 on Linux):
    fgetcsv($FP, 2048, ";", "\"");

    JOn

    Comment

    • Matthew Crouch

      #3
      Re: on the bleeding edge, not sure I belong there...stream_ get_line()


      "Jon Kraft" <jon@jonux.co.u k> wrote in message
      news:Xns9468B6E A86C9Ejonjonuxc ouk@130.133.1.4 ...[color=blue]
      > "Matthew Crouch" <matthew.crouch @spamlessverizo n.net> wrote:
      >[color=green]
      > > "spykids.jpg";" na.jpg";"noQval ue";"0.45";"S py Kids";"<big><b> This is a
      > > previously-viewed DVD in the original case. Both the DVD and case are
      > > in excellent condition and come with a life-time guarantee.
      > > </big></b><br><br>
      > >
      > > <b>The Original One!</B><br>
      > > (2002) Color - 88 Minutes
      > > <br><BR>
      > >
      > > ...and so on
      > >
      > > So the usual fgetcsv() doesn't work -- it interprets each new-line as
      > > a new record (even though it's enclosed within double quotes).[/color]
      >
      > It works fine on my system (PHP 4.3.2 on Linux):
      > fgetcsv($FP, 2048, ";", "\"");
      >
      > JOn[/color]

      Very true, thank you. I wasn't using the optional delimiters. Time for
      another pot of coffee, I guess.


      Comment

      Working...