in reply to Re^2: Need to create CSV using Text::CSV
in thread Need to create CSV using Text::CSV

It will create an extra empty line in between each record.

Yes, exactly. The OP wrote:

I got the following input:

a,b,c,d,e,f....etc.

I was hoping something like this:

a,b

c,d

e,f

etc...

showing a blank line between each pair of output lines — from which I took it that the extra line was a requirement. But see the caveat at the end of my post.

Regards,

Athanasius <°(((><contra mundum

  • Comment on Re^3: Need to create CSV using Text::CSV

Replies are listed 'Best First'.
Re^4: Need to create CSV using Text::CSV
by CountZero (Bishop) on Jun 17, 2012 at 14:28 UTC
    Indeed, you are right. I missed the extra empty lines.

    Strange kind of CSV file though, with empty lines.

    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

    My blog: Imperial Deltronics
Re^4: Need to create CSV using Text::CSV
by oldwarrior32 (Sexton) on Jun 17, 2012 at 17:14 UTC

    Sorry for the misleading. But I don't want an empty line between the records. I just don't know yet how to post some lines with out empty lines between. I just use the paragraph tag that insert an empty line between written lines. Besides the programs works without empty lines that is what I was looking for.

    Update: I learned already. This is the desired output:

    a,b
    c,d
    e,f
    etc...

    Update2: I think now I undestand what you mean. In a text file the line feed is invisible(at least I don't see blank line between the data using notepad), but when I pasted the data to Excel I saw the blank lines. So, I changed the code to: $csv->eol("\n"); and no blank spaces are seen.

    Thanks!

      It isn't wrong per sé, but why not put the eol attribute in the constructor?

      my $csv = Text::CSV ({ binary => 1, eol => "\n", auto_diag => 1 });

      To convert CSV to XLS, Text::CSV_XS comes with the csv2xls script in the examples folder, so if XLS is your target format, you could use that.


      Enjoy, Have FUN! H.Merijn

        I did that but didn't worked.