in reply to CSV problem
in thread CSV problem

I dunno. It doesn't work for some reason:

open (OUT, ">Curr_Closed.csv"); open (RAW, "<Prelim_CC.csv") or die "ERROR: Could not open Curr_Cl +osed.csv"; while (<RAW>){ chomp ($_); my @columns = split (/,/, $_, 10); $columns[9] =~ s/,/;/; print OUT $columns[9]."\n"} close (RAW); close (OUT);

What this does is takes only the first comma in 10th column and changes it to semilon. But fields that have more than one comma are still messed up.

Am I using regexp wrong?

Replies are listed 'Best First'.
Re^2: CSV problem
by Anonymous Monk on Mar 07, 2008 at 17:57 UTC
    Yes, you need g on the end

    $columns9 =~ s/,/;/g;

    Untested.

    J.C.