Hi Perl Monks, I have what seems to me a pretty large request -- so I'm offering a $50 donation to Perl Monks for the solution. It's not alot -- but it's the best I can do right now and I'm super short on time :( I have an old perl wiki (chiq chaq) with 500+ records that I'm trying to import into a database. I'd like to convert the chiq chaq data into a csv file so I can then manipulate, move around, etc... Chiq chaq saves it's data into separate text files in a directory, one for each record. The file names look like this:
wing.chiq wing.chiq.20040417130658 wing.chiq.20040417130727 wing.chiq.20040418184654 woodies.chiq words_with_question_marks.chiq
The contents of record looks like this:
{*JohnDoe* (Wednesday, September 08, 2004, 11:43): A wing is a chemical additive that hastens [[cure]] or chemical reacti +on. For example, cobalt is a wing for [[MEKP]]-catalyzed polyester_r +esin. See, promoted_resin. (_Category_A_) }
I'd like to convert this into a CSV row that looks like this:
wing, JohnDoe, 1094643780, "An accelerator is a chemical additive that + hastens [[cure]] or chemical reaction. For example, cobalt is an ac +celerator for [[MEKP]]-catalyzed polyester_resin. See, promoted_resin +. (_Category_A_)"
I'm leaving in the [word] strings because I can remove those once the text is in csv. I'm also leaving in the "(_Category_A_)" cause it's random... Please note, I forget how to handle large chunks of text that can have commas when converting to csv...do you wrap it in ""? What if there's quotes in the text block? uugh. I'd like the script to read in one file at a time, and save it to a csv file. Any help will be greatly appreciated...

In reply to complex text file to csv by mpaler

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.