Hello all,

Been a long time since I've been here, but I'm encountering a problem I need some assistance. Hopefully it's something easy, but I just can't see to get the code to work how I want it too.

So, I have this csv file that I want to parse. but the problem is, the person who was updating the spreadsheet put "newlines" in the cells (using alt+return I believe). So, as you can imagine, when I'm trying to parse the file, one record maybe contain several lines in the file.

What I would like to do is replace the new lines (or returns) with
so when I update to our database, and view with a browser, the format is preserves. I'm doing the replacement with  $_ =~ s/(\r+|\n+)/<br>/g;. Which is working, but it's putting
in places that I don't want.

Example, 1. The first line in the csv file is each of the column names, I don't need
there. 2. The start of each new records begins with a "TC-" so I don't need a
at the very end of that record either. Again, the record may be several lines (it varies), until the next "TC-" is found.

Any thoughts ???

Thanks all !!!


In reply to Parsing a CSV file in a unique way by TASdvlper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.