in reply to Re: Reading Multiple lines
in thread Reading Multiple lines

When I open the file I have the correct pattern

eg Input is.
"data","data","data","data"
"data","data with 
new with new Line" "data"
"data","data","data","data"

"data","data","data","data"
"data","data with new with new Line" "data"
"data","data","data","data"
I'm not sure if I need to use that module.As, at this point in the process I don't process the fields and only process each line

Replies are listed 'Best First'.
Re^3: Reading Multiple lines
by moritz (Cardinal) on Oct 15, 2008 at 09:33 UTC
    Oh, I should have read your code more thoroughly.
    <code> "data","data","data","data" "data","data with new with new Line" "data"

    It would be more consistent to put a comma between the two last fields, not just a blank.

    If you do that, you can just feed the lines to Text::CSV. Or reinvent the wheel by crafting a clever regex, but that has been discussed here many times (try Super Search for CSV or "comma separated"), so I won't re-write the wheel.

      sorry I missed that the comma in that example. it should be.
      
      input:
      "data", "data" ,"data", "data","data", "data"
      "data", "data" ,"data", "data
      with new line
      ","data", "data"
      "data", "data" ,"data", "data","data", "data"
      
      output:
      "data", "data" ,"data", "data","data", "data"
      "data", "data" ,"data", "data with new line","data", "data"
      "data", "data" ,"data", "data","data", "data"
      
      All I am doing at this stage is making sure that the line
      ends with a quotation mark. I would prefer not to use the TEXT::CSV module as this will be used on a server
      that I don't have permissions to load modules.
        Get permission, its much easier than re-inventing wheels (esp. when you're having problems doing it). Try (cut/paste) Text::CSV_PP - Text::CSV_XS compatible pure-Perl module