in reply to Replace commas with spaces between quotes, parsing CSV

You could try Text::ParseWords

#!perl use strict; use Time::Piece; use Text::ParseWords; use Data::Dumper; my @data = (); while (my $line = <DATA>){ my @fields = quotewords(',', 0, $line); unshift @fields, join '_', @fields[0..2]; s/,//g for @fields[7,19]; $_ = join '-', (split /\//)[2,0,1] for @fields[14,20,23]; $_ = Time::Piece->strptime($_,'%m/%d/%Y %H:%M')->strftime('%Y-%m-%d +%H:%M') for @fields[38,39]; push @data,\@fields; } print Dumper \@data; __DATA__ 1925,47365,2,650187016,1,1,"MADE, FOR, DRAWDOWNS, NEVER, P/U",16,IFC 8 +112NP,Standalone-6,,,44,10/22/2015,91607,,B24W02651,,"PA-3, PURE",4/2 +8/2015,1,0,,1,MAN,,CUST,,CUSTOM MATCH,0,TRUE,TRUE,O,C48A0D001EF449E3A +B97F0B98C811B1B,POS.MISTINT.V0000.UP.Q,PROD_SMISA_BK,414D512050524F44 +5F504F5331393235906F28561D2F0020,10/22/2015 9:29,10/22/2015 9:30
poj

Replies are listed 'Best First'.
Re^2: Replace commas with spaces between quotes, parsing CSV
by BigRedEO (Acolyte) on Apr 15, 2016 at 19:05 UTC
    Except that has appeared to put commas in every space in the quoted fields? Rather than replace any commas in the quoted fields with spaces?