Sadly I had a case a couple years ago where the data had commas and quotes and probably other characters (possibly embedded cr/lf in a file which split lines and had continued on the next line markers and probably quoting inconsistencies and other weird stuff) and as a result the various Text::CSV variations did not work and I do not think I figured out what the problem was. I do not remember if the code crashed or just returned the wrong result. I ended up writing a pure perl routine (mostly brute force things but also used index and substr optimizations) to do the split and the problem was solved (with a fair amount of pain). it also seems to work handling csv files from Excel Worksheets (at least the ones I work with). I guess the lesson (for me at least) is that sometimes you have to grow your own solution.

I may have tried other splitting routines that were suggested at various sites without any luck - I just cannot remember.

maybe someday I will go back to the code and retry the processing with the Text::CSV code to see what the problem is so that (maybe) the Text::CSV code can be fixed. at that time I may include my code. I check these things I respond to periodically (not daily - more like every couple weeks) so if someone expresses some interest I may post the code I used before I retest.


In reply to Re: CSV SPLIT by Anonymous Monk
in thread CSV SPLIT by serene_monk

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.