hmmm if you are just wondering on how to print to a csv file you can just use the IO::File and Text::CSV_XS. If you go check out the documentation of Text::CSV_XS and IO::File what happens is that you scan in your csv file 1 line at a time and each line is put into an array. Anyways, you can do something like

use Text::CSV_XS; use IO::File; use strict; my $csv = Text::CSV_XS->new({sep_char => "\t"}); my %hashed; open my $in, '<', $input1 or die "Read Failed: $!\n"; while(<$in>) { $csv->parse( $_ ) or warn "Bad data: $_\n", next; my @row = $csv->fields(); $hashed{ $row[0] } = \@row; } close $in; my $fh = new IO::File "> $output"; foreach my $hash ( %hashed) { if($hashed{$hash}) { $csv->combine(@{$hashed{$hash}}); print "$hash has data $hashed{ $hash }->[0]\n"; $fh->print($csv->string, "\n"); } } $fh->close;

This is just a basic read in of a csv file that is tab separated. All of the input and csv manipulation can be found in Text::CSV_XS documentation. But to output the file in csv format the easiest way I found was with IO::File.


In reply to Re^3: Process and combine two CSV files into one by Thargor
in thread Process and combine two CSV files into one by DrAxeman

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.