I for the life of me cannot find a useful example for my needs. I am looking for a simple example of parsing a text file and creating a CSV file. For example something that converts this text file:

Line1info Line2someMoreInfo Line3 more info Line5line4IsBlank Line6isTabbed Line7isToo Line8hasMoreStuff

into this CSV file:

Line1, Line3, Line6, Line7 Line1info, Line3 more info, Line6isTabbed, Line7isToo

I figured this would be a common request but apparently I was wrong. Every example I've found does not fit the bill. If someone could point me to an example that I could use as a template to learn from that would be great. If it is easy to produce an example from the generic data I provided that would be great too.

Just in case being more specific is helpful, here is exactly what I'm trying to do

Flat File

NetDevice1234 Kernel: Linux 2.6.18-164.11 Version: Driver 23.4.1 333.0 Hotfix BLD Edition Hot fixes: HF372590 HF372804 HF372864 Enabled Features: FTP HTTP SMTP Active Directory

Into a CVS with the following contents:

Host, OS, Version, Hot Fixes, Features NetDevice1234, Linux 2.6.18-164.11, Driver 23.4.1 333.0 Hotfix BLD Edi +tion, HF372590 HF372804 HF372864, FTP HTTP SMTP Active Directory

Thanks for any help you can provide everyone!


In reply to Simple parse of text file to csv by OodaLoop

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.