I 100% concur with dorward -- this is something that modules like Text::CSV were born to do. The split solution works for simple cases, but once you start trying to deal with text delimiters, quotes within delimiters, and commas within text, you'll be aching for that module.

I'm not 100% certain what you're aiming for, so let me first mention that .csv files should open in Excel with no trouble, in most cases. That kind of auto-convert might save you a lot of trouble, so if all you need to do is open your .csv file in Excel, I recommend that approach strongly.

Otherwise...my understanding, and please correct if I'm wrong, is that you've written a split based conversation already, yes? If it's broken, and you simply cannot install the Text::CSV module, please edit your post here w/the text of the code that's not working, so we can help you properly.

That good for you?

----Asim, known to some as Woodrow.


In reply to Re: Comma delimited file manipulation -- help required. by Asim
in thread Comma delimited file manipulation -- help required. by swetashah23

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.