in reply to Get CSV data and convert it to other format data dynamically.

Have a look at Array::Transpose for the column to row transposition once you've read in with Text::CSV (as mentioned above).

  • Comment on Re: Get CSV data and convert it to other format data dynamically.

Replies are listed 'Best First'.
Re^2: Get CSV data and convert it to other format data dynamically.
by ash1351 (Novice) on Aug 24, 2015 at 21:22 UTC
    Hi VinsWorldcom, The text file has csv data itself. I didnt get why we need to use Text:CSV first and then proceed. We can straight away use Array::Transpose ??

      Text::CSV offers a more robust interface than:

      my @csv; while (<$fh>) { chomp $_; my @p = split /,/, $_; push @csv, \@p; }

      or something like that. If your goal is to be robust, I'd use the module that is solely dedicated to reading that type of data and then another that helps you transform it. Not sure about the JSON output, you're getting a bit out of my league there, but again, if you're looking for robust, readable, supportable code, use the module that's been vetted by all CPAN'ers versus rolling your own.