in reply to Strict Ref : ERROR

Try small steps first ... can you correctly parse the data and output sql?

#!/usr/bin/perl use strict; use Text::CSV_XS; my $csv = Text::CSV_XS->new(); my $sqlf = "insert into acct1 ( date, time, RAS_CLIENT, Called_Station_Id, Calling_Station_Id, Acct_Input_Octets, Acct_Output_Octets, Acct_Session_Time, Acct_Input_Packets, Acct_Output_Packets, Acct_Termination_Cause ) values( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )"; while( <> ) { if( $csv->parse( $_ ) ) { my @vals = $csv->fields(); printf( $sqlf, $vals[0], $vals[1], $vals[2], $vals[28], $vals[29], $vals[34], $vals[35], $vals[38], $vals[39], $vals[40], $vals[41], $vals[42] ); } else { print "Error: " , $csv->error_input(); } }
That will at least get you started (and show that at least one of your example records isn't really following the de-facto CSV standard). Once you can properly create the sql ... move onto the next step.

-derby

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.