in reply to Re: complex text file to csv
in thread complex text file to csv

uugh. Sorry for the missing/inconsistent info.

Let me try again...

I have a directory 1000 text files with names as follows...

... barnyard.chiq beach_bum.chiq belly.chiq belly.chiq.20040413103234 belly.chiq.20040417092739 belly.chiq.20040417093935 # <-- Last created file berry.chiq bert.chiq ...
If you opened any of files (for example belly above), it would look like this:
{*JohnDoe* (Saturday, April 10, 2004, 10:41): Belly is a term used to describe a rounded surfboard bottom, when view +ed from the front or rear (not from the side). }
What I'm looking to do is convert & import the last created file for each record into one big .csv file. Each record needs to map to the csv as follows (still using belly):
Belly, JohnDoe, 1081593660, "Belly is a term used to describe a rounde +d surfboard bottom, when viewed from the front or rear (not from the +side)."
Notes: First column in csv is the title of the file minus the extension. Ideally filenames like "beach_bum" can be converted to "Beach Bum." Third column in csv is date converted to unix timestamp. Fourth column is content b/w the : and the last } -- this text block can have any type of character in it, including quotes, commas, etc.

Again, sorry for the laim first post -- and my $50 contrib to Perl Monks stands...

Replies are listed 'Best First'.
Re^3: complex text file to csv
by CountZero (Bishop) on Jun 05, 2009 at 18:10 UTC
    Will the content always start on the second line of the file and end at the first EOL-character or or is it really one big stream with possibly multiple EOL-characters inside the content?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      The latter is true. Here's two more examples with variable EOLs:
      {*JohnDoe* (Thursday, April 01, 2004, 16:04): CATALYST A substance that changes the rate of a chemical reaction without itsel +f undergoing permanent change in composition or becoming a part of th +e molecular structure of the product. A catalyst markedly speeds up t +he cure of a compound when added in minor quantity as compared to the + amounts of primary reactants. See, Methyl_Ethyl_Ketone_Peroxide }
      and
      {*KeithMelville* (Thursday, April 01, 2004, 16:23): CHEATER COAT 1) Resin applied to wood, especially porous ones such as balsa_wood, b +efore laminating as a pre-treatment, to prevent a dry_spot in the lam +ination caused by wood soaking up the resin. 2) Basting of laps or low spots with laminating resin before a hot_coa +t is sometimes called a cheater_coat. See [[basting]]. }